Merged in ValentinaZhuravska/valentina/feature (pull request #78)
Tests for SumTrapezoids method in VAbstractDetail class --HG-- branch : develop
This commit is contained in:
commit
4c3eae4c80
|
@ -32,6 +32,8 @@
|
|||
#include <QPointF>
|
||||
#include <QVector>
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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<QPointF> points = InputPointsCase1(); // Input points.
|
||||
|
@ -78,6 +92,33 @@ void TST_VAbstractDetail::Case2() const
|
|||
Comparison(ekv, ekvOrig);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TST_VAbstractDetail::Case3() const
|
||||
{
|
||||
const QVector<QPointF> points = InputPointsCase3(); // Input points.
|
||||
|
||||
const qreal result = VAbstractDetail::SumTrapezoids(points);
|
||||
QVERIFY(result < 0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TST_VAbstractDetail::Case4() const
|
||||
{
|
||||
const QVector<QPointF> points = InputPointsCase4(); // Input points.
|
||||
|
||||
const qreal result = VAbstractDetail::SumTrapezoids(points);
|
||||
QVERIFY(result > 0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TST_VAbstractDetail::Case5() const
|
||||
{
|
||||
const QVector<QPointF> points = InputPointsCase5(); // Input points.
|
||||
|
||||
const qreal result = VAbstractDetail::SumTrapezoids(points);
|
||||
QVERIFY(result == 0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> TST_VAbstractDetail::InputPointsCase1() const
|
||||
{
|
||||
|
@ -324,3 +365,37 @@ QVector<QPointF> TST_VAbstractDetail::OutputPointsCase2() const
|
|||
|
||||
return points;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> TST_VAbstractDetail::InputPointsCase3() const
|
||||
{
|
||||
QVector<QPointF> points;
|
||||
|
||||
points += QPointF(35, 35);
|
||||
points += QPointF(50, 50);
|
||||
points += QPointF(15, 50);
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> TST_VAbstractDetail::InputPointsCase4() const
|
||||
{
|
||||
QVector<QPointF> points;
|
||||
|
||||
points += QPointF(15, 15);
|
||||
points += QPointF(15, 50);
|
||||
points += QPointF(50, 50);
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> TST_VAbstractDetail::InputPointsCase5() const
|
||||
{
|
||||
QVector<QPointF> points;
|
||||
|
||||
points += QPointF(35, 35);
|
||||
|
||||
return points;
|
||||
}
|
||||
|
|
|
@ -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<QPointF> InputPointsCase1() const;
|
||||
QVector<QPointF> OutputPointsCase1() const;
|
||||
|
@ -52,6 +56,10 @@ private:
|
|||
QVector<QPointF> InputPointsCase2() const;
|
||||
QVector<QPointF> OutputPointsCase2() const;
|
||||
|
||||
QVector<QPointF> InputPointsCase3() const;
|
||||
QVector<QPointF> InputPointsCase4() const;
|
||||
QVector<QPointF> InputPointsCase5() const;
|
||||
|
||||
};
|
||||
|
||||
#endif // TST_VABSTRACTDETAIL_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user