From 8d87ca989f2006405d0c15bd8d1538156fcf77c5 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 2 Jan 2019 15:58:59 +0200 Subject: [PATCH] Improving tests. Comparisons for TST_FindPoint is too precise. ref #918. --HG-- branch : release --- src/libs/vtest/abstracttest.cpp | 9 +++++++++ src/libs/vtest/abstracttest.h | 1 + src/test/ValentinaTest/tst_findpoint.cpp | 21 ++++++++++++--------- src/test/ValentinaTest/tst_findpoint.h | 4 ++-- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/libs/vtest/abstracttest.cpp b/src/libs/vtest/abstracttest.cpp index ee4ba2a19..63f89eb94 100644 --- a/src/libs/vtest/abstracttest.cpp +++ b/src/libs/vtest/abstracttest.cpp @@ -73,6 +73,15 @@ void AbstractTest::Comparison(const QVector &ekv, const QVector &ekv, const QVector &ekvOrig) const; + void Comparison(const QPointF &result, const QPointF &expected) const; QString ValentinaPath() const; QString TapePath() const; diff --git a/src/test/ValentinaTest/tst_findpoint.cpp b/src/test/ValentinaTest/tst_findpoint.cpp index 24d423b4f..f27560a14 100644 --- a/src/test/ValentinaTest/tst_findpoint.cpp +++ b/src/test/ValentinaTest/tst_findpoint.cpp @@ -37,8 +37,8 @@ #include //--------------------------------------------------------------------------------------------------------------------- -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(vCross), static_cast(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); } diff --git a/src/test/ValentinaTest/tst_findpoint.h b/src/test/ValentinaTest/tst_findpoint.h index a56142a15..313b3ae32 100644 --- a/src/test/ValentinaTest/tst_findpoint.h +++ b/src/test/ValentinaTest/tst_findpoint.h @@ -29,9 +29,9 @@ #ifndef TST_FINDPOINT_H #define TST_FINDPOINT_H -#include +#include "../vtest/abstracttest.h" -class TST_FindPoint : public QObject +class TST_FindPoint : public AbstractTest { Q_OBJECT public: