diff --git a/src/test/ValentinaTest/tst_vabstractdetail.cpp b/src/test/ValentinaTest/tst_vabstractdetail.cpp index 60db36b21..ccb824db8 100644 --- a/src/test/ValentinaTest/tst_vabstractdetail.cpp +++ b/src/test/ValentinaTest/tst_vabstractdetail.cpp @@ -32,6 +32,8 @@ #include #include +#include + //--------------------------------------------------------------------------------------------------------------------- TST_VAbstractDetail::TST_VAbstractDetail(QObject *parent) :AbstractTest(parent) @@ -51,6 +53,18 @@ void TST_VAbstractDetail::EquidistantRemoveLoop() const } //--------------------------------------------------------------------------------------------------------------------- +void TST_VAbstractDetail::SumTrapezoids() const +{ + // Case3 checks that the method 'SumTrapezoids' returns negative value for three clockwise allocated points + // Case4 checks that the method 'SumTrapezoids' returns positive value for three counterclock-wise allocated points + // Case5 checks that the method 'SumTrapezoids' returns 0 for one point + Case3(); + Case4(); + Case5(); +} + +//--------------------------------------------------------------------------------------------------------------------- + void TST_VAbstractDetail::Case1() const { const QVector points = InputPointsCase1(); // Input points. @@ -78,6 +92,33 @@ void TST_VAbstractDetail::Case2() const Comparison(ekv, ekvOrig); } +//--------------------------------------------------------------------------------------------------------------------- +void TST_VAbstractDetail::Case3() const +{ + const QVector points = InputPointsCase3(); // Input points. + + const qreal result = VAbstractDetail::SumTrapezoids(points); + QVERIFY(result < 0); +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_VAbstractDetail::Case4() const +{ + const QVector points = InputPointsCase4(); // Input points. + + const qreal result = VAbstractDetail::SumTrapezoids(points); + QVERIFY(result > 0); +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_VAbstractDetail::Case5() const +{ + const QVector points = InputPointsCase5(); // Input points. + + const qreal result = VAbstractDetail::SumTrapezoids(points); + QVERIFY(result == 0); +} + //--------------------------------------------------------------------------------------------------------------------- QVector TST_VAbstractDetail::InputPointsCase1() const { @@ -324,3 +365,37 @@ QVector TST_VAbstractDetail::OutputPointsCase2() const return points; } + +//--------------------------------------------------------------------------------------------------------------------- +QVector TST_VAbstractDetail::InputPointsCase3() const +{ + QVector points; + + points += QPointF(35, 35); + points += QPointF(50, 50); + points += QPointF(15, 50); + + return points; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector TST_VAbstractDetail::InputPointsCase4() const +{ + QVector points; + + points += QPointF(15, 15); + points += QPointF(15, 50); + points += QPointF(50, 50); + + return points; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector TST_VAbstractDetail::InputPointsCase5() const +{ + QVector points; + + points += QPointF(35, 35); + + return points; +} diff --git a/src/test/ValentinaTest/tst_vabstractdetail.h b/src/test/ValentinaTest/tst_vabstractdetail.h index 44b729a38..83790c743 100644 --- a/src/test/ValentinaTest/tst_vabstractdetail.h +++ b/src/test/ValentinaTest/tst_vabstractdetail.h @@ -41,10 +41,14 @@ signals: private slots: void EquidistantRemoveLoop() const; + void SumTrapezoids() const; private: void Case1() const; void Case2() const; + void Case3() const; + void Case4() const; + void Case5() const; QVector InputPointsCase1() const; QVector OutputPointsCase1() const; @@ -52,6 +56,10 @@ private: QVector InputPointsCase2() const; QVector OutputPointsCase2() const; + QVector InputPointsCase3() const; + QVector InputPointsCase4() const; + QVector InputPointsCase5() const; + }; #endif // TST_VABSTRACTDETAIL_H