Improving tests. Comparisons for TST_FindPoint is too precise. ref #918.
(grafted from 0a47a319a9450b3d30f0d7f8d00675628744d58a) --HG-- branch : develop
This commit is contained in:
parent
3dfa269224
commit
b825a9084e
|
@ -73,6 +73,15 @@ void AbstractTest::Comparison(const QVector<QPointF> &ekv, const QVector<QPointF
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AbstractTest::Comparison(const QPointF &result, const QPointF &expected) const
|
||||
{
|
||||
const QString msg = QStringLiteral("Got '%2;%3', Expected '%4;%5'.")
|
||||
.arg(result.x()).arg(result.y()).arg(expected.x()).arg(expected.y());
|
||||
// Check each point. Don't use comparison float values
|
||||
QVERIFY2(VFuzzyComparePoints(result, expected), qUtf8Printable(msg));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString AbstractTest::ValentinaPath() const
|
||||
{
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
|
||||
protected:
|
||||
void Comparison(const QVector<QPointF> &ekv, const QVector<QPointF> &ekvOrig) const;
|
||||
void Comparison(const QPointF &result, const QPointF &expected) const;
|
||||
|
||||
QString ValentinaPath() const;
|
||||
QString TapePath() const;
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
#include <QtTest>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
TST_FindPoint::TST_FindPoint(QObject *parent) :
|
||||
QObject(parent)
|
||||
TST_FindPoint::TST_FindPoint(QObject *parent)
|
||||
: AbstractTest(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,8 @@ void TST_FindPoint::TestPointOfIntersectionCurves()
|
|||
VToolPointOfIntersectionCurves::FindPoint(curve1Points, curve2Points,
|
||||
static_cast<VCrossCurvesPoint>(vCross),
|
||||
static_cast<HCrossCurvesPoint>(hCross), &result);
|
||||
QCOMPARE(result.toPoint(), expect.toPoint());
|
||||
|
||||
Comparison(result, expect);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -210,8 +211,8 @@ void TST_FindPoint::TestTrueDarts()
|
|||
|
||||
VToolTrueDarts::FindPoint(baseLineP1, baseLineP2, dartP1, dartP2, dartP3, p1, p2);
|
||||
|
||||
QCOMPARE(p1.toPoint(), expectP1.toPoint());
|
||||
QCOMPARE(p2.toPoint(), expectP2.toPoint());
|
||||
Comparison(p1, expectP1);
|
||||
Comparison(p2, expectP2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -237,7 +238,8 @@ void TST_FindPoint::TestLineIntersectAxis()
|
|||
|
||||
QPointF resultPoint;
|
||||
VToolLineIntersectAxis::FindPoint(axis, line, &resultPoint);
|
||||
QCOMPARE(point, resultPoint);
|
||||
|
||||
Comparison(resultPoint, point);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -269,7 +271,8 @@ void TST_FindPoint::TestTriangle()
|
|||
|
||||
QPointF resultPoint;
|
||||
VToolTriangle::FindPoint(axisP1, axisP2, firstPoint, secondPoint, &resultPoint);
|
||||
QCOMPARE(point, resultPoint);
|
||||
|
||||
Comparison(point, resultPoint);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -309,7 +312,7 @@ void TST_FindPoint::TestShoulderPoint()
|
|||
|
||||
QPointF resultPoint = VToolShoulderPoint::FindPoint(p1, p2, pShoulder, length);
|
||||
|
||||
QCOMPARE(point, resultPoint);
|
||||
Comparison(point, resultPoint);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -549,5 +552,5 @@ void TST_FindPoint::TestCurveIntersectAxis()
|
|||
QPointF resultPoint;
|
||||
VToolCurveIntersectAxis::FindPoint(basePoint, angle, curvePoints, &resultPoint);
|
||||
|
||||
QCOMPARE(result, resultPoint);
|
||||
Comparison(resultPoint, result);
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
#ifndef TST_FINDPOINT_H
|
||||
#define TST_FINDPOINT_H
|
||||
|
||||
#include <QObject>
|
||||
#include "../vtest/abstracttest.h"
|
||||
|
||||
class TST_FindPoint : public QObject
|
||||
class TST_FindPoint : public AbstractTest
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue
Block a user