Testlib: Format QVector2/3/4D in QCOMPARE
Change-Id: Ia0709e598d2fddd6c2f448633b484749146265f7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
ca0df4b269
commit
eb93d7b517
@ -59,6 +59,9 @@
|
||||
#include <QtGui/qpixmap.h>
|
||||
#include <QtGui/qimage.h>
|
||||
#include <QtGui/qregion.h>
|
||||
#include <QtGui/qvector2d.h>
|
||||
#include <QtGui/qvector3d.h>
|
||||
#include <QtGui/qvector4d.h>
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
#include <QtGui/qicon.h>
|
||||
@ -116,6 +119,32 @@ template<> inline char *toString(const QRegion ®ion)
|
||||
return qstrdup(result.constData());
|
||||
}
|
||||
|
||||
#ifndef QT_NO_VECTOR2D
|
||||
template<> inline char *toString(const QVector2D &v)
|
||||
{
|
||||
QByteArray result = "QVector2D(" + QByteArray::number(v.x()) + ", "
|
||||
+ QByteArray::number(v.y()) + ')';
|
||||
return qstrdup(result.constData());
|
||||
}
|
||||
#endif // !QT_NO_VECTOR2D
|
||||
#ifndef QT_NO_VECTOR3D
|
||||
template<> inline char *toString(const QVector3D &v)
|
||||
{
|
||||
QByteArray result = "QVector3D(" + QByteArray::number(v.x()) + ", "
|
||||
+ QByteArray::number(v.y()) + ", " + QByteArray::number(v.z()) + ')';
|
||||
return qstrdup(result.constData());
|
||||
}
|
||||
#endif // !QT_NO_VECTOR3D
|
||||
#ifndef QT_NO_VECTOR4D
|
||||
template<> inline char *toString(const QVector4D &v)
|
||||
{
|
||||
QByteArray result = "QVector4D(" + QByteArray::number(v.x()) + ", "
|
||||
+ QByteArray::number(v.y()) + ", " + QByteArray::number(v.z())
|
||||
+ ", " + QByteArray::number(v.w()) + ')';
|
||||
return qstrdup(result.constData());
|
||||
}
|
||||
#endif // !QT_NO_VECTOR4D
|
||||
|
||||
inline bool qCompare(QIcon const &t1, QIcon const &t2, const char *actual, const char *expected,
|
||||
const char *file, int line)
|
||||
{
|
||||
|
@ -33,6 +33,9 @@
|
||||
#include <QtGui/QColor>
|
||||
#include <QtGui/QImage>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QVector2D>
|
||||
#include <QtGui/QVector3D>
|
||||
#include <QtGui/QVector4D>
|
||||
#endif
|
||||
|
||||
/* XPM test data for QPixmap, QImage tests (use drag cursors as example) */
|
||||
@ -144,6 +147,9 @@ private slots:
|
||||
void compareQImages_data();
|
||||
void compareQRegion_data();
|
||||
void compareQRegion();
|
||||
void compareQVector2D();
|
||||
void compareQVector3D();
|
||||
void compareQVector4D();
|
||||
#endif
|
||||
void verify();
|
||||
void verify2();
|
||||
@ -454,6 +460,33 @@ void tst_Cmptest::compareQRegion()
|
||||
|
||||
QCOMPARE(rA, rB);
|
||||
}
|
||||
|
||||
void tst_Cmptest::compareQVector2D()
|
||||
{
|
||||
QVector2D v2a{1, 2};
|
||||
QVector2D v2b = v2a;
|
||||
QCOMPARE(v2a, v2b);
|
||||
v2b.setY(3);
|
||||
QCOMPARE(v2a, v2b);
|
||||
}
|
||||
|
||||
void tst_Cmptest::compareQVector3D()
|
||||
{
|
||||
QVector3D v3a{1, 2, 3};
|
||||
QVector3D v3b = v3a;
|
||||
QCOMPARE(v3a, v3b);
|
||||
v3b.setY(3);
|
||||
QCOMPARE(v3a, v3b);
|
||||
}
|
||||
|
||||
void tst_Cmptest::compareQVector4D()
|
||||
{
|
||||
QVector4D v4a{1, 2, 3, 4};
|
||||
QVector4D v4b = v4a;
|
||||
QCOMPARE(v4a, v4b);
|
||||
v4b.setY(3);
|
||||
QCOMPARE(v4a, v4b);
|
||||
}
|
||||
#endif // QT_GUI_LIB
|
||||
|
||||
static int opaqueFunc()
|
||||
|
@ -223,6 +223,30 @@
|
||||
</Incident>
|
||||
<Duration msecs="0"/>
|
||||
</TestFunction>
|
||||
<TestFunction name="compareQVector2D">
|
||||
<Incident type="fail" file="tst_cmptest.cpp" line="0">
|
||||
<Description><![CDATA[Compared values are not the same
|
||||
Actual (v2a): QVector2D(1, 2)
|
||||
Expected (v2b): QVector2D(1, 3)]]></Description>
|
||||
</Incident>
|
||||
<Duration msecs="0"/>
|
||||
</TestFunction>
|
||||
<TestFunction name="compareQVector3D">
|
||||
<Incident type="fail" file="tst_cmptest.cpp" line="0">
|
||||
<Description><![CDATA[Compared values are not the same
|
||||
Actual (v3a): QVector3D(1, 2, 3)
|
||||
Expected (v3b): QVector3D(1, 3, 3)]]></Description>
|
||||
</Incident>
|
||||
<Duration msecs="0"/>
|
||||
</TestFunction>
|
||||
<TestFunction name="compareQVector4D">
|
||||
<Incident type="fail" file="tst_cmptest.cpp" line="0">
|
||||
<Description><![CDATA[Compared values are not the same
|
||||
Actual (v4a): QVector4D(1, 2, 3, 4)
|
||||
Expected (v4b): QVector4D(1, 3, 3, 4)]]></Description>
|
||||
</Incident>
|
||||
<Duration msecs="0"/>
|
||||
</TestFunction>
|
||||
<TestFunction name="verify">
|
||||
<Incident type="fail" file="tst_cmptest.cpp" line="467">
|
||||
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
|
||||
|
@ -103,6 +103,15 @@
|
||||
##teamcity[testStarted name='compareQRegion(different lists)' flowId='tst_Cmptest']
|
||||
##teamcity[testFailed name='compareQRegion(different lists)' message='Failure! |[Loc: tst_cmptest.cpp(455)|]' details='Compared values are not the same|n Actual (rA): QRegion(200x50+10+10)|n Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10)' flowId='tst_Cmptest']
|
||||
##teamcity[testFinished name='compareQRegion(different lists)' flowId='tst_Cmptest']
|
||||
##teamcity[testStarted name='compareQVector2D()' flowId='tst_Cmptest']
|
||||
##teamcity[testFailed name='compareQVector2D()' message='Failure! |[Loc: tst_cmptest.cpp(0)|]' details='Compared values are not the same|n Actual (v2a): QVector2D(1, 2)|n Expected (v2b): QVector2D(1, 3)' flowId='tst_Cmptest']
|
||||
##teamcity[testFinished name='compareQVector2D()' flowId='tst_Cmptest']
|
||||
##teamcity[testStarted name='compareQVector3D()' flowId='tst_Cmptest']
|
||||
##teamcity[testFailed name='compareQVector3D()' message='Failure! |[Loc: tst_cmptest.cpp(0)|]' details='Compared values are not the same|n Actual (v3a): QVector3D(1, 2, 3)|n Expected (v3b): QVector3D(1, 3, 3)' flowId='tst_Cmptest']
|
||||
##teamcity[testFinished name='compareQVector3D()' flowId='tst_Cmptest']
|
||||
##teamcity[testStarted name='compareQVector4D()' flowId='tst_Cmptest']
|
||||
##teamcity[testFailed name='compareQVector4D()' message='Failure! |[Loc: tst_cmptest.cpp(0)|]' details='Compared values are not the same|n Actual (v4a): QVector4D(1, 2, 3, 4)|n Expected (v4b): QVector4D(1, 3, 3, 4)' flowId='tst_Cmptest']
|
||||
##teamcity[testFinished name='compareQVector4D()' flowId='tst_Cmptest']
|
||||
##teamcity[testStarted name='verify()' flowId='tst_Cmptest']
|
||||
##teamcity[testFailed name='verify()' message='Failure! |[Loc: tst_cmptest.cpp(467)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()' flowId='tst_Cmptest']
|
||||
##teamcity[testFinished name='verify()' flowId='tst_Cmptest']
|
||||
|
@ -111,6 +111,18 @@ FAIL! : tst_Cmptest::compareQRegion(different lists) Compared values are not th
|
||||
Actual (rA): QRegion(200x50+10+10)
|
||||
Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10)
|
||||
Loc: [tst_cmptest.cpp(455)]
|
||||
FAIL! : tst_Cmptest::compareQVector2D() Compared values are not the same
|
||||
Actual (v2a): QVector2D(1, 2)
|
||||
Expected (v2b): QVector2D(1, 3)
|
||||
Loc: [tst_cmptest.cpp(0)]
|
||||
FAIL! : tst_Cmptest::compareQVector3D() Compared values are not the same
|
||||
Actual (v3a): QVector3D(1, 2, 3)
|
||||
Expected (v3b): QVector3D(1, 3, 3)
|
||||
Loc: [tst_cmptest.cpp(0)]
|
||||
FAIL! : tst_Cmptest::compareQVector4D() Compared values are not the same
|
||||
Actual (v4a): QVector4D(1, 2, 3, 4)
|
||||
Expected (v4b): QVector4D(1, 3, 3, 4)
|
||||
Loc: [tst_cmptest.cpp(0)]
|
||||
FAIL! : tst_Cmptest::verify() 'opaqueFunc() < 2' returned FALSE. ()
|
||||
Loc: [tst_cmptest.cpp(467)]
|
||||
FAIL! : tst_Cmptest::verify2() 'opaqueFunc() < 2' returned FALSE. (42)
|
||||
@ -121,5 +133,5 @@ FAIL! : tst_Cmptest::tryVerify2() 'opaqueFunc() < 2' returned FALSE. (42)
|
||||
Loc: [tst_cmptest.cpp(485)]
|
||||
PASS : tst_Cmptest::verifyExplicitOperatorBool()
|
||||
PASS : tst_Cmptest::cleanupTestCase()
|
||||
Totals: 15 passed, 30 failed, 0 skipped, 0 blacklisted, 244ms
|
||||
Totals: 15 passed, 33 failed, 0 skipped, 0 blacklisted, 0ms
|
||||
********* Finished testing of tst_Cmptest *********
|
||||
|
@ -225,6 +225,30 @@
|
||||
</Incident>
|
||||
<Duration msecs="0"/>
|
||||
</TestFunction>
|
||||
<TestFunction name="compareQVector2D">
|
||||
<Incident type="fail" file="tst_cmptest.cpp" line="0">
|
||||
<Description><![CDATA[Compared values are not the same
|
||||
Actual (v2a): QVector2D(1, 2)
|
||||
Expected (v2b): QVector2D(1, 3)]]></Description>
|
||||
</Incident>
|
||||
<Duration msecs="0"/>
|
||||
</TestFunction>
|
||||
<TestFunction name="compareQVector3D">
|
||||
<Incident type="fail" file="tst_cmptest.cpp" line="0">
|
||||
<Description><![CDATA[Compared values are not the same
|
||||
Actual (v3a): QVector3D(1, 2, 3)
|
||||
Expected (v3b): QVector3D(1, 3, 3)]]></Description>
|
||||
</Incident>
|
||||
<Duration msecs="0"/>
|
||||
</TestFunction>
|
||||
<TestFunction name="compareQVector4D">
|
||||
<Incident type="fail" file="tst_cmptest.cpp" line="0">
|
||||
<Description><![CDATA[Compared values are not the same
|
||||
Actual (v4a): QVector4D(1, 2, 3, 4)
|
||||
Expected (v4b): QVector4D(1, 3, 3, 4)]]></Description>
|
||||
</Incident>
|
||||
<Duration msecs="0"/>
|
||||
</TestFunction>
|
||||
<TestFunction name="verify">
|
||||
<Incident type="fail" file="tst_cmptest.cpp" line="467">
|
||||
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<testsuite errors="0" failures="30" tests="21" name="tst_Cmptest">
|
||||
<testsuite errors="0" failures="33" tests="24" name="tst_Cmptest">
|
||||
<properties>
|
||||
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
|
||||
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
|
||||
@ -103,6 +103,21 @@
|
||||
Actual (rA): QRegion(200x50+10+10)
|
||||
Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10)" result="fail"/>
|
||||
</testcase>
|
||||
<testcase result="fail" name="compareQVector2D">
|
||||
<failure message="Compared values are not the same
|
||||
Actual (v2a): QVector2D(1, 2)
|
||||
Expected (v2b): QVector2D(1, 3)" result="fail"/>
|
||||
</testcase>
|
||||
<testcase result="fail" name="compareQVector3D">
|
||||
<failure message="Compared values are not the same
|
||||
Actual (v3a): QVector3D(1, 2, 3)
|
||||
Expected (v3b): QVector3D(1, 3, 3)" result="fail"/>
|
||||
</testcase>
|
||||
<testcase result="fail" name="compareQVector4D">
|
||||
<failure message="Compared values are not the same
|
||||
Actual (v4a): QVector4D(1, 2, 3, 4)
|
||||
Expected (v4b): QVector4D(1, 3, 3, 4)" result="fail"/>
|
||||
</testcase>
|
||||
<testcase result="fail" name="verify">
|
||||
<failure message="'opaqueFunc() < 2' returned FALSE. ()" result="fail"/>
|
||||
</testcase>
|
||||
|
Loading…
x
Reference in New Issue
Block a user