Fix QCOMPARE with enum classes.

As these are strongly typed, they won't implicitly convert to int, so make sure
to cast explicitly.

Change-Id: Ic8daa31c528bbd8f399ab401d0963e13db191312
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Robin Burchell 2015-11-01 16:41:25 +01:00 committed by Robin Burchell
parent d8f41bdc2e
commit 9626baaea9
6 changed files with 117 additions and 81 deletions

View File

@ -238,7 +238,7 @@ namespace QTest
inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, char*>::Type toString(T e) inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, char*>::Type toString(T e)
{ {
QMetaEnum me = QMetaEnum::fromType<T>(); QMetaEnum me = QMetaEnum::fromType<T>();
return qstrdup(me.key(e)); return qstrdup(me.key(int(e))); // int cast is necessary to support enum classes
} }
template <typename T> // Fallback template <typename T> // Fallback

View File

@ -123,9 +123,14 @@ class tst_Cmptest: public QObject
{ {
Q_OBJECT Q_OBJECT
public:
enum class MyClassEnum { MyClassEnumValue1, MyClassEnumValue2 };
Q_ENUM(MyClassEnum)
private slots: private slots:
void compare_unregistered_enums(); void compare_unregistered_enums();
void compare_registered_enums(); void compare_registered_enums();
void compare_class_enums();
void compare_boolfuncs(); void compare_boolfuncs();
void compare_pointerfuncs(); void compare_pointerfuncs();
void compare_tostring(); void compare_tostring();
@ -160,6 +165,12 @@ void tst_Cmptest::compare_registered_enums()
QCOMPARE(Qt::ArrowCursor, Qt::BusyCursor); QCOMPARE(Qt::ArrowCursor, Qt::BusyCursor);
} }
void tst_Cmptest::compare_class_enums()
{
QCOMPARE(MyClassEnum::MyClassEnumValue1, MyClassEnum::MyClassEnumValue1);
QCOMPARE(MyClassEnum::MyClassEnumValue1, MyClassEnum::MyClassEnumValue2);
}
static bool boolfunc() { return true; } static bool boolfunc() { return true; }
static bool boolfunc2() { return true; } static bool boolfunc2() { return true; }

View File

@ -8,19 +8,27 @@
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="compare_unregistered_enums"> <TestFunction name="compare_unregistered_enums">
<Incident type="fail" file="tst_cmptest.cpp" line="154"> <Incident type="fail" file="tst_cmptest.cpp" line="159">
<Description><![CDATA[Compared values are not the same]]></Description> <Description><![CDATA[Compared values are not the same]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="compare_registered_enums"> <TestFunction name="compare_registered_enums">
<Incident type="fail" file="tst_cmptest.cpp" line="160"> <Incident type="fail" file="tst_cmptest.cpp" line="165">
<Description><![CDATA[Compared values are not the same <Description><![CDATA[Compared values are not the same
Actual (Qt::ArrowCursor): ArrowCursor Actual (Qt::ArrowCursor): ArrowCursor
Expected (Qt::BusyCursor) : BusyCursor]]></Description> Expected (Qt::BusyCursor) : BusyCursor]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="compare_class_enums">
<Incident type="fail" file="tst_cmptest.cpp" line="171">
<Description><![CDATA[Compared values are not the same
Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1
Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_boolfuncs"> <TestFunction name="compare_boolfuncs">
<Incident type="pass" file="" line="0" /> <Incident type="pass" file="" line="0" />
<Duration msecs="0"/> <Duration msecs="0"/>
@ -30,7 +38,7 @@
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="compare_tostring"> <TestFunction name="compare_tostring">
<Incident type="fail" file="tst_cmptest.cpp" line="231"> <Incident type="fail" file="tst_cmptest.cpp" line="242">
<DataTag><![CDATA[int, string]]></DataTag> <DataTag><![CDATA[int, string]]></DataTag>
<Description><![CDATA[Compared values are not the same <Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(int,123) Actual (actual) : QVariant(int,123)
@ -39,19 +47,19 @@
<Incident type="pass" file="" line="0"> <Incident type="pass" file="" line="0">
<DataTag><![CDATA[both invalid]]></DataTag> <DataTag><![CDATA[both invalid]]></DataTag>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="231"> <Incident type="fail" file="tst_cmptest.cpp" line="242">
<DataTag><![CDATA[null hash, invalid]]></DataTag> <DataTag><![CDATA[null hash, invalid]]></DataTag>
<Description><![CDATA[Compared values are not the same <Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(QVariantHash) Actual (actual) : QVariant(QVariantHash)
Expected (expected): QVariant()]]></Description> Expected (expected): QVariant()]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="231"> <Incident type="fail" file="tst_cmptest.cpp" line="242">
<DataTag><![CDATA[string, null user type]]></DataTag> <DataTag><![CDATA[string, null user type]]></DataTag>
<Description><![CDATA[Compared values are not the same <Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(QString,A simple string) Actual (actual) : QVariant(QString,A simple string)
Expected (expected): QVariant(PhonyClass)]]></Description> Expected (expected): QVariant(PhonyClass)]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="231"> <Incident type="fail" file="tst_cmptest.cpp" line="242">
<DataTag><![CDATA[both non-null user type]]></DataTag> <DataTag><![CDATA[both non-null user type]]></DataTag>
<Description><![CDATA[Compared values are not the same <Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(PhonyClass,<value not representable as string>) Actual (actual) : QVariant(PhonyClass,<value not representable as string>)
@ -66,31 +74,31 @@
<Incident type="pass" file="" line="0"> <Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal lists]]></DataTag> <DataTag><![CDATA[equal lists]]></DataTag>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="325"> <Incident type="fail" file="tst_cmptest.cpp" line="336">
<DataTag><![CDATA[last item different]]></DataTag> <DataTag><![CDATA[last item different]]></DataTag>
<Description><![CDATA[Compared lists differ at index 2. <Description><![CDATA[Compared lists differ at index 2.
Actual (opA): "string3" Actual (opA): "string3"
Expected (opB): "DIFFERS"]]></Description> Expected (opB): "DIFFERS"]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="325"> <Incident type="fail" file="tst_cmptest.cpp" line="336">
<DataTag><![CDATA[second-last item different]]></DataTag> <DataTag><![CDATA[second-last item different]]></DataTag>
<Description><![CDATA[Compared lists differ at index 2. <Description><![CDATA[Compared lists differ at index 2.
Actual (opA): "string3" Actual (opA): "string3"
Expected (opB): "DIFFERS"]]></Description> Expected (opB): "DIFFERS"]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="325"> <Incident type="fail" file="tst_cmptest.cpp" line="336">
<DataTag><![CDATA[prefix]]></DataTag> <DataTag><![CDATA[prefix]]></DataTag>
<Description><![CDATA[Compared lists have different sizes. <Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 2 Actual (opA) size: 2
Expected (opB) size: 1]]></Description> Expected (opB) size: 1]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="325"> <Incident type="fail" file="tst_cmptest.cpp" line="336">
<DataTag><![CDATA[short list second]]></DataTag> <DataTag><![CDATA[short list second]]></DataTag>
<Description><![CDATA[Compared lists have different sizes. <Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 12 Actual (opA) size: 12
Expected (opB) size: 1]]></Description> Expected (opB) size: 1]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="325"> <Incident type="fail" file="tst_cmptest.cpp" line="336">
<DataTag><![CDATA[short list first]]></DataTag> <DataTag><![CDATA[short list first]]></DataTag>
<Description><![CDATA[Compared lists have different sizes. <Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 1 Actual (opA) size: 1
@ -99,7 +107,7 @@
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="compareQListInt"> <TestFunction name="compareQListInt">
<Incident type="fail" file="tst_cmptest.cpp" line="332"> <Incident type="fail" file="tst_cmptest.cpp" line="343">
<Description><![CDATA[Compared lists differ at index 2. <Description><![CDATA[Compared lists differ at index 2.
Actual (int1): 3 Actual (int1): 3
Expected (int2): 4]]></Description> Expected (int2): 4]]></Description>
@ -107,7 +115,7 @@
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="compareQListDouble"> <TestFunction name="compareQListDouble">
<Incident type="fail" file="tst_cmptest.cpp" line="339"> <Incident type="fail" file="tst_cmptest.cpp" line="350">
<Description><![CDATA[Compared lists differ at index 0. <Description><![CDATA[Compared lists differ at index 0.
Actual (double1): 1.5 Actual (double1): 1.5
Expected (double2): 1]]></Description> Expected (double2): 1]]></Description>
@ -118,13 +126,13 @@
<Incident type="pass" file="" line="0"> <Incident type="pass" file="" line="0">
<DataTag><![CDATA[both null]]></DataTag> <DataTag><![CDATA[both null]]></DataTag>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="365"> <Incident type="fail" file="tst_cmptest.cpp" line="376">
<DataTag><![CDATA[one null]]></DataTag> <DataTag><![CDATA[one null]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ. <Description><![CDATA[Compared QPixmaps differ.
Actual (opA).isNull(): 1 Actual (opA).isNull(): 1
Expected (opB).isNull(): 0]]></Description> Expected (opB).isNull(): 0]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="365"> <Incident type="fail" file="tst_cmptest.cpp" line="376">
<DataTag><![CDATA[other null]]></DataTag> <DataTag><![CDATA[other null]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ. <Description><![CDATA[Compared QPixmaps differ.
Actual (opA).isNull(): 0 Actual (opA).isNull(): 0
@ -133,13 +141,13 @@
<Incident type="pass" file="" line="0"> <Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal]]></DataTag> <DataTag><![CDATA[equal]]></DataTag>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="365"> <Incident type="fail" file="tst_cmptest.cpp" line="376">
<DataTag><![CDATA[different size]]></DataTag> <DataTag><![CDATA[different size]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ in size. <Description><![CDATA[Compared QPixmaps differ in size.
Actual (opA): 11x20 Actual (opA): 11x20
Expected (opB): 20x20]]></Description> Expected (opB): 20x20]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="365"> <Incident type="fail" file="tst_cmptest.cpp" line="376">
<DataTag><![CDATA[different pixels]]></DataTag> <DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description> <Description><![CDATA[Compared values are not the same]]></Description>
</Incident> </Incident>
@ -149,13 +157,13 @@
<Incident type="pass" file="" line="0"> <Incident type="pass" file="" line="0">
<DataTag><![CDATA[both null]]></DataTag> <DataTag><![CDATA[both null]]></DataTag>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="392"> <Incident type="fail" file="tst_cmptest.cpp" line="403">
<DataTag><![CDATA[one null]]></DataTag> <DataTag><![CDATA[one null]]></DataTag>
<Description><![CDATA[Compared QImages differ. <Description><![CDATA[Compared QImages differ.
Actual (opA).isNull(): 1 Actual (opA).isNull(): 1
Expected (opB).isNull(): 0]]></Description> Expected (opB).isNull(): 0]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="392"> <Incident type="fail" file="tst_cmptest.cpp" line="403">
<DataTag><![CDATA[other null]]></DataTag> <DataTag><![CDATA[other null]]></DataTag>
<Description><![CDATA[Compared QImages differ. <Description><![CDATA[Compared QImages differ.
Actual (opA).isNull(): 0 Actual (opA).isNull(): 0
@ -164,44 +172,44 @@
<Incident type="pass" file="" line="0"> <Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal]]></DataTag> <DataTag><![CDATA[equal]]></DataTag>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="392"> <Incident type="fail" file="tst_cmptest.cpp" line="403">
<DataTag><![CDATA[different size]]></DataTag> <DataTag><![CDATA[different size]]></DataTag>
<Description><![CDATA[Compared QImages differ in size. <Description><![CDATA[Compared QImages differ in size.
Actual (opA): 11x20 Actual (opA): 11x20
Expected (opB): 20x20]]></Description> Expected (opB): 20x20]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="392"> <Incident type="fail" file="tst_cmptest.cpp" line="403">
<DataTag><![CDATA[different format]]></DataTag> <DataTag><![CDATA[different format]]></DataTag>
<Description><![CDATA[Compared QImages differ in format. <Description><![CDATA[Compared QImages differ in format.
Actual (opA): 6 Actual (opA): 6
Expected (opB): 3]]></Description> Expected (opB): 3]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="392"> <Incident type="fail" file="tst_cmptest.cpp" line="403">
<DataTag><![CDATA[different pixels]]></DataTag> <DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description> <Description><![CDATA[Compared values are not the same]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="verify"> <TestFunction name="verify">
<Incident type="fail" file="tst_cmptest.cpp" line="404"> <Incident type="fail" file="tst_cmptest.cpp" line="415">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="verify2"> <TestFunction name="verify2">
<Incident type="fail" file="tst_cmptest.cpp" line="410"> <Incident type="fail" file="tst_cmptest.cpp" line="421">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="tryVerify"> <TestFunction name="tryVerify">
<Incident type="fail" file="tst_cmptest.cpp" line="416"> <Incident type="fail" file="tst_cmptest.cpp" line="427">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="tryVerify2"> <TestFunction name="tryVerify2">
<Incident type="fail" file="tst_cmptest.cpp" line="422"> <Incident type="fail" file="tst_cmptest.cpp" line="433">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>

View File

@ -2,104 +2,108 @@
Config: Using QtTest library Config: Using QtTest library
PASS : tst_Cmptest::initTestCase() PASS : tst_Cmptest::initTestCase()
FAIL! : tst_Cmptest::compare_unregistered_enums() Compared values are not the same FAIL! : tst_Cmptest::compare_unregistered_enums() Compared values are not the same
Loc: [tst_cmptest.cpp(154)] Loc: [tst_cmptest.cpp(159)]
FAIL! : tst_Cmptest::compare_registered_enums() Compared values are not the same FAIL! : tst_Cmptest::compare_registered_enums() Compared values are not the same
Actual (Qt::ArrowCursor): ArrowCursor Actual (Qt::ArrowCursor): ArrowCursor
Expected (Qt::BusyCursor) : BusyCursor Expected (Qt::BusyCursor) : BusyCursor
Loc: [tst_cmptest.cpp(160)] Loc: [tst_cmptest.cpp(165)]
FAIL! : tst_Cmptest::compare_class_enums() Compared values are not the same
Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1
Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2
Loc: [tst_cmptest.cpp(171)]
PASS : tst_Cmptest::compare_boolfuncs() PASS : tst_Cmptest::compare_boolfuncs()
PASS : tst_Cmptest::compare_pointerfuncs() PASS : tst_Cmptest::compare_pointerfuncs()
FAIL! : tst_Cmptest::compare_tostring(int, string) Compared values are not the same FAIL! : tst_Cmptest::compare_tostring(int, string) Compared values are not the same
Actual (actual) : QVariant(int,123) Actual (actual) : QVariant(int,123)
Expected (expected): QVariant(QString,hi) Expected (expected): QVariant(QString,hi)
Loc: [tst_cmptest.cpp(231)] Loc: [tst_cmptest.cpp(242)]
PASS : tst_Cmptest::compare_tostring(both invalid) PASS : tst_Cmptest::compare_tostring(both invalid)
FAIL! : tst_Cmptest::compare_tostring(null hash, invalid) Compared values are not the same FAIL! : tst_Cmptest::compare_tostring(null hash, invalid) Compared values are not the same
Actual (actual) : QVariant(QVariantHash) Actual (actual) : QVariant(QVariantHash)
Expected (expected): QVariant() Expected (expected): QVariant()
Loc: [tst_cmptest.cpp(231)] Loc: [tst_cmptest.cpp(242)]
FAIL! : tst_Cmptest::compare_tostring(string, null user type) Compared values are not the same FAIL! : tst_Cmptest::compare_tostring(string, null user type) Compared values are not the same
Actual (actual) : QVariant(QString,A simple string) Actual (actual) : QVariant(QString,A simple string)
Expected (expected): QVariant(PhonyClass) Expected (expected): QVariant(PhonyClass)
Loc: [tst_cmptest.cpp(231)] Loc: [tst_cmptest.cpp(242)]
FAIL! : tst_Cmptest::compare_tostring(both non-null user type) Compared values are not the same FAIL! : tst_Cmptest::compare_tostring(both non-null user type) Compared values are not the same
Actual (actual) : QVariant(PhonyClass,<value not representable as string>) Actual (actual) : QVariant(PhonyClass,<value not representable as string>)
Expected (expected): QVariant(PhonyClass,<value not representable as string>) Expected (expected): QVariant(PhonyClass,<value not representable as string>)
Loc: [tst_cmptest.cpp(231)] Loc: [tst_cmptest.cpp(242)]
PASS : tst_Cmptest::compareQStringLists(empty lists) PASS : tst_Cmptest::compareQStringLists(empty lists)
PASS : tst_Cmptest::compareQStringLists(equal lists) PASS : tst_Cmptest::compareQStringLists(equal lists)
FAIL! : tst_Cmptest::compareQStringLists(last item different) Compared lists differ at index 2. FAIL! : tst_Cmptest::compareQStringLists(last item different) Compared lists differ at index 2.
Actual (opA): "string3" Actual (opA): "string3"
Expected (opB): "DIFFERS" Expected (opB): "DIFFERS"
Loc: [tst_cmptest.cpp(325)] Loc: [tst_cmptest.cpp(336)]
FAIL! : tst_Cmptest::compareQStringLists(second-last item different) Compared lists differ at index 2. FAIL! : tst_Cmptest::compareQStringLists(second-last item different) Compared lists differ at index 2.
Actual (opA): "string3" Actual (opA): "string3"
Expected (opB): "DIFFERS" Expected (opB): "DIFFERS"
Loc: [tst_cmptest.cpp(325)] Loc: [tst_cmptest.cpp(336)]
FAIL! : tst_Cmptest::compareQStringLists(prefix) Compared lists have different sizes. FAIL! : tst_Cmptest::compareQStringLists(prefix) Compared lists have different sizes.
Actual (opA) size: 2 Actual (opA) size: 2
Expected (opB) size: 1 Expected (opB) size: 1
Loc: [tst_cmptest.cpp(325)] Loc: [tst_cmptest.cpp(336)]
FAIL! : tst_Cmptest::compareQStringLists(short list second) Compared lists have different sizes. FAIL! : tst_Cmptest::compareQStringLists(short list second) Compared lists have different sizes.
Actual (opA) size: 12 Actual (opA) size: 12
Expected (opB) size: 1 Expected (opB) size: 1
Loc: [tst_cmptest.cpp(325)] Loc: [tst_cmptest.cpp(336)]
FAIL! : tst_Cmptest::compareQStringLists(short list first) Compared lists have different sizes. FAIL! : tst_Cmptest::compareQStringLists(short list first) Compared lists have different sizes.
Actual (opA) size: 1 Actual (opA) size: 1
Expected (opB) size: 12 Expected (opB) size: 12
Loc: [tst_cmptest.cpp(325)] Loc: [tst_cmptest.cpp(336)]
FAIL! : tst_Cmptest::compareQListInt() Compared lists differ at index 2. FAIL! : tst_Cmptest::compareQListInt() Compared lists differ at index 2.
Actual (int1): 3 Actual (int1): 3
Expected (int2): 4 Expected (int2): 4
Loc: [tst_cmptest.cpp(332)] Loc: [tst_cmptest.cpp(343)]
FAIL! : tst_Cmptest::compareQListDouble() Compared lists differ at index 0. FAIL! : tst_Cmptest::compareQListDouble() Compared lists differ at index 0.
Actual (double1): 1.5 Actual (double1): 1.5
Expected (double2): 1 Expected (double2): 1
Loc: [tst_cmptest.cpp(339)] Loc: [tst_cmptest.cpp(350)]
PASS : tst_Cmptest::compareQPixmaps(both null) PASS : tst_Cmptest::compareQPixmaps(both null)
FAIL! : tst_Cmptest::compareQPixmaps(one null) Compared QPixmaps differ. FAIL! : tst_Cmptest::compareQPixmaps(one null) Compared QPixmaps differ.
Actual (opA).isNull(): 1 Actual (opA).isNull(): 1
Expected (opB).isNull(): 0 Expected (opB).isNull(): 0
Loc: [tst_cmptest.cpp(365)] Loc: [tst_cmptest.cpp(376)]
FAIL! : tst_Cmptest::compareQPixmaps(other null) Compared QPixmaps differ. FAIL! : tst_Cmptest::compareQPixmaps(other null) Compared QPixmaps differ.
Actual (opA).isNull(): 0 Actual (opA).isNull(): 0
Expected (opB).isNull(): 1 Expected (opB).isNull(): 1
Loc: [tst_cmptest.cpp(365)] Loc: [tst_cmptest.cpp(376)]
PASS : tst_Cmptest::compareQPixmaps(equal) PASS : tst_Cmptest::compareQPixmaps(equal)
FAIL! : tst_Cmptest::compareQPixmaps(different size) Compared QPixmaps differ in size. FAIL! : tst_Cmptest::compareQPixmaps(different size) Compared QPixmaps differ in size.
Actual (opA): 11x20 Actual (opA): 11x20
Expected (opB): 20x20 Expected (opB): 20x20
Loc: [tst_cmptest.cpp(365)] Loc: [tst_cmptest.cpp(376)]
FAIL! : tst_Cmptest::compareQPixmaps(different pixels) Compared values are not the same FAIL! : tst_Cmptest::compareQPixmaps(different pixels) Compared values are not the same
Loc: [tst_cmptest.cpp(365)] Loc: [tst_cmptest.cpp(376)]
PASS : tst_Cmptest::compareQImages(both null) PASS : tst_Cmptest::compareQImages(both null)
FAIL! : tst_Cmptest::compareQImages(one null) Compared QImages differ. FAIL! : tst_Cmptest::compareQImages(one null) Compared QImages differ.
Actual (opA).isNull(): 1 Actual (opA).isNull(): 1
Expected (opB).isNull(): 0 Expected (opB).isNull(): 0
Loc: [tst_cmptest.cpp(392)] Loc: [tst_cmptest.cpp(403)]
FAIL! : tst_Cmptest::compareQImages(other null) Compared QImages differ. FAIL! : tst_Cmptest::compareQImages(other null) Compared QImages differ.
Actual (opA).isNull(): 0 Actual (opA).isNull(): 0
Expected (opB).isNull(): 1 Expected (opB).isNull(): 1
Loc: [tst_cmptest.cpp(392)] Loc: [tst_cmptest.cpp(403)]
PASS : tst_Cmptest::compareQImages(equal) PASS : tst_Cmptest::compareQImages(equal)
FAIL! : tst_Cmptest::compareQImages(different size) Compared QImages differ in size. FAIL! : tst_Cmptest::compareQImages(different size) Compared QImages differ in size.
Actual (opA): 11x20 Actual (opA): 11x20
Expected (opB): 20x20 Expected (opB): 20x20
Loc: [tst_cmptest.cpp(392)] Loc: [tst_cmptest.cpp(403)]
FAIL! : tst_Cmptest::compareQImages(different format) Compared QImages differ in format. FAIL! : tst_Cmptest::compareQImages(different format) Compared QImages differ in format.
Actual (opA): 6 Actual (opA): 6
Expected (opB): 3 Expected (opB): 3
Loc: [tst_cmptest.cpp(392)] Loc: [tst_cmptest.cpp(403)]
FAIL! : tst_Cmptest::compareQImages(different pixels) Compared values are not the same FAIL! : tst_Cmptest::compareQImages(different pixels) Compared values are not the same
Loc: [tst_cmptest.cpp(392)] Loc: [tst_cmptest.cpp(403)]
FAIL! : tst_Cmptest::verify() 'opaqueFunc() < 2' returned FALSE. () FAIL! : tst_Cmptest::verify() 'opaqueFunc() < 2' returned FALSE. ()
Loc: [tst_cmptest.cpp(404)] Loc: [tst_cmptest.cpp(415)]
FAIL! : tst_Cmptest::verify2() 'opaqueFunc() < 2' returned FALSE. (42) FAIL! : tst_Cmptest::verify2() 'opaqueFunc() < 2' returned FALSE. (42)
Loc: [tst_cmptest.cpp(410)] Loc: [tst_cmptest.cpp(421)]
FAIL! : tst_Cmptest::tryVerify() 'opaqueFunc() < 2' returned FALSE. () FAIL! : tst_Cmptest::tryVerify() 'opaqueFunc() < 2' returned FALSE. ()
Loc: [tst_cmptest.cpp(416)] Loc: [tst_cmptest.cpp(427)]
FAIL! : tst_Cmptest::tryVerify2() 'opaqueFunc() < 2' returned FALSE. (42) FAIL! : tst_Cmptest::tryVerify2() 'opaqueFunc() < 2' returned FALSE. (42)
Loc: [tst_cmptest.cpp(422)] Loc: [tst_cmptest.cpp(433)]
PASS : tst_Cmptest::cleanupTestCase() PASS : tst_Cmptest::cleanupTestCase()
Totals: 11 passed, 26 failed, 0 skipped, 0 blacklisted Totals: 11 passed, 27 failed, 0 skipped, 0 blacklisted
********* Finished testing of tst_Cmptest ********* ********* Finished testing of tst_Cmptest *********

View File

@ -10,19 +10,27 @@
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="compare_unregistered_enums"> <TestFunction name="compare_unregistered_enums">
<Incident type="fail" file="tst_cmptest.cpp" line="154"> <Incident type="fail" file="tst_cmptest.cpp" line="159">
<Description><![CDATA[Compared values are not the same]]></Description> <Description><![CDATA[Compared values are not the same]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="compare_registered_enums"> <TestFunction name="compare_registered_enums">
<Incident type="fail" file="tst_cmptest.cpp" line="160"> <Incident type="fail" file="tst_cmptest.cpp" line="165">
<Description><![CDATA[Compared values are not the same <Description><![CDATA[Compared values are not the same
Actual (Qt::ArrowCursor): ArrowCursor Actual (Qt::ArrowCursor): ArrowCursor
Expected (Qt::BusyCursor) : BusyCursor]]></Description> Expected (Qt::BusyCursor) : BusyCursor]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="compare_class_enums">
<Incident type="fail" file="tst_cmptest.cpp" line="171">
<Description><![CDATA[Compared values are not the same
Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1
Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_boolfuncs"> <TestFunction name="compare_boolfuncs">
<Incident type="pass" file="" line="0" /> <Incident type="pass" file="" line="0" />
<Duration msecs="0"/> <Duration msecs="0"/>
@ -32,7 +40,7 @@
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="compare_tostring"> <TestFunction name="compare_tostring">
<Incident type="fail" file="tst_cmptest.cpp" line="231"> <Incident type="fail" file="tst_cmptest.cpp" line="242">
<DataTag><![CDATA[int, string]]></DataTag> <DataTag><![CDATA[int, string]]></DataTag>
<Description><![CDATA[Compared values are not the same <Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(int,123) Actual (actual) : QVariant(int,123)
@ -41,19 +49,19 @@
<Incident type="pass" file="" line="0"> <Incident type="pass" file="" line="0">
<DataTag><![CDATA[both invalid]]></DataTag> <DataTag><![CDATA[both invalid]]></DataTag>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="231"> <Incident type="fail" file="tst_cmptest.cpp" line="242">
<DataTag><![CDATA[null hash, invalid]]></DataTag> <DataTag><![CDATA[null hash, invalid]]></DataTag>
<Description><![CDATA[Compared values are not the same <Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(QVariantHash) Actual (actual) : QVariant(QVariantHash)
Expected (expected): QVariant()]]></Description> Expected (expected): QVariant()]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="231"> <Incident type="fail" file="tst_cmptest.cpp" line="242">
<DataTag><![CDATA[string, null user type]]></DataTag> <DataTag><![CDATA[string, null user type]]></DataTag>
<Description><![CDATA[Compared values are not the same <Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(QString,A simple string) Actual (actual) : QVariant(QString,A simple string)
Expected (expected): QVariant(PhonyClass)]]></Description> Expected (expected): QVariant(PhonyClass)]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="231"> <Incident type="fail" file="tst_cmptest.cpp" line="242">
<DataTag><![CDATA[both non-null user type]]></DataTag> <DataTag><![CDATA[both non-null user type]]></DataTag>
<Description><![CDATA[Compared values are not the same <Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(PhonyClass,<value not representable as string>) Actual (actual) : QVariant(PhonyClass,<value not representable as string>)
@ -68,31 +76,31 @@
<Incident type="pass" file="" line="0"> <Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal lists]]></DataTag> <DataTag><![CDATA[equal lists]]></DataTag>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="325"> <Incident type="fail" file="tst_cmptest.cpp" line="336">
<DataTag><![CDATA[last item different]]></DataTag> <DataTag><![CDATA[last item different]]></DataTag>
<Description><![CDATA[Compared lists differ at index 2. <Description><![CDATA[Compared lists differ at index 2.
Actual (opA): "string3" Actual (opA): "string3"
Expected (opB): "DIFFERS"]]></Description> Expected (opB): "DIFFERS"]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="325"> <Incident type="fail" file="tst_cmptest.cpp" line="336">
<DataTag><![CDATA[second-last item different]]></DataTag> <DataTag><![CDATA[second-last item different]]></DataTag>
<Description><![CDATA[Compared lists differ at index 2. <Description><![CDATA[Compared lists differ at index 2.
Actual (opA): "string3" Actual (opA): "string3"
Expected (opB): "DIFFERS"]]></Description> Expected (opB): "DIFFERS"]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="325"> <Incident type="fail" file="tst_cmptest.cpp" line="336">
<DataTag><![CDATA[prefix]]></DataTag> <DataTag><![CDATA[prefix]]></DataTag>
<Description><![CDATA[Compared lists have different sizes. <Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 2 Actual (opA) size: 2
Expected (opB) size: 1]]></Description> Expected (opB) size: 1]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="325"> <Incident type="fail" file="tst_cmptest.cpp" line="336">
<DataTag><![CDATA[short list second]]></DataTag> <DataTag><![CDATA[short list second]]></DataTag>
<Description><![CDATA[Compared lists have different sizes. <Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 12 Actual (opA) size: 12
Expected (opB) size: 1]]></Description> Expected (opB) size: 1]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="325"> <Incident type="fail" file="tst_cmptest.cpp" line="336">
<DataTag><![CDATA[short list first]]></DataTag> <DataTag><![CDATA[short list first]]></DataTag>
<Description><![CDATA[Compared lists have different sizes. <Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 1 Actual (opA) size: 1
@ -101,7 +109,7 @@
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="compareQListInt"> <TestFunction name="compareQListInt">
<Incident type="fail" file="tst_cmptest.cpp" line="332"> <Incident type="fail" file="tst_cmptest.cpp" line="343">
<Description><![CDATA[Compared lists differ at index 2. <Description><![CDATA[Compared lists differ at index 2.
Actual (int1): 3 Actual (int1): 3
Expected (int2): 4]]></Description> Expected (int2): 4]]></Description>
@ -109,7 +117,7 @@
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="compareQListDouble"> <TestFunction name="compareQListDouble">
<Incident type="fail" file="tst_cmptest.cpp" line="339"> <Incident type="fail" file="tst_cmptest.cpp" line="350">
<Description><![CDATA[Compared lists differ at index 0. <Description><![CDATA[Compared lists differ at index 0.
Actual (double1): 1.5 Actual (double1): 1.5
Expected (double2): 1]]></Description> Expected (double2): 1]]></Description>
@ -120,13 +128,13 @@
<Incident type="pass" file="" line="0"> <Incident type="pass" file="" line="0">
<DataTag><![CDATA[both null]]></DataTag> <DataTag><![CDATA[both null]]></DataTag>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="365"> <Incident type="fail" file="tst_cmptest.cpp" line="376">
<DataTag><![CDATA[one null]]></DataTag> <DataTag><![CDATA[one null]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ. <Description><![CDATA[Compared QPixmaps differ.
Actual (opA).isNull(): 1 Actual (opA).isNull(): 1
Expected (opB).isNull(): 0]]></Description> Expected (opB).isNull(): 0]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="365"> <Incident type="fail" file="tst_cmptest.cpp" line="376">
<DataTag><![CDATA[other null]]></DataTag> <DataTag><![CDATA[other null]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ. <Description><![CDATA[Compared QPixmaps differ.
Actual (opA).isNull(): 0 Actual (opA).isNull(): 0
@ -135,13 +143,13 @@
<Incident type="pass" file="" line="0"> <Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal]]></DataTag> <DataTag><![CDATA[equal]]></DataTag>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="365"> <Incident type="fail" file="tst_cmptest.cpp" line="376">
<DataTag><![CDATA[different size]]></DataTag> <DataTag><![CDATA[different size]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ in size. <Description><![CDATA[Compared QPixmaps differ in size.
Actual (opA): 11x20 Actual (opA): 11x20
Expected (opB): 20x20]]></Description> Expected (opB): 20x20]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="365"> <Incident type="fail" file="tst_cmptest.cpp" line="376">
<DataTag><![CDATA[different pixels]]></DataTag> <DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description> <Description><![CDATA[Compared values are not the same]]></Description>
</Incident> </Incident>
@ -151,13 +159,13 @@
<Incident type="pass" file="" line="0"> <Incident type="pass" file="" line="0">
<DataTag><![CDATA[both null]]></DataTag> <DataTag><![CDATA[both null]]></DataTag>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="392"> <Incident type="fail" file="tst_cmptest.cpp" line="403">
<DataTag><![CDATA[one null]]></DataTag> <DataTag><![CDATA[one null]]></DataTag>
<Description><![CDATA[Compared QImages differ. <Description><![CDATA[Compared QImages differ.
Actual (opA).isNull(): 1 Actual (opA).isNull(): 1
Expected (opB).isNull(): 0]]></Description> Expected (opB).isNull(): 0]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="392"> <Incident type="fail" file="tst_cmptest.cpp" line="403">
<DataTag><![CDATA[other null]]></DataTag> <DataTag><![CDATA[other null]]></DataTag>
<Description><![CDATA[Compared QImages differ. <Description><![CDATA[Compared QImages differ.
Actual (opA).isNull(): 0 Actual (opA).isNull(): 0
@ -166,44 +174,44 @@
<Incident type="pass" file="" line="0"> <Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal]]></DataTag> <DataTag><![CDATA[equal]]></DataTag>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="392"> <Incident type="fail" file="tst_cmptest.cpp" line="403">
<DataTag><![CDATA[different size]]></DataTag> <DataTag><![CDATA[different size]]></DataTag>
<Description><![CDATA[Compared QImages differ in size. <Description><![CDATA[Compared QImages differ in size.
Actual (opA): 11x20 Actual (opA): 11x20
Expected (opB): 20x20]]></Description> Expected (opB): 20x20]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="392"> <Incident type="fail" file="tst_cmptest.cpp" line="403">
<DataTag><![CDATA[different format]]></DataTag> <DataTag><![CDATA[different format]]></DataTag>
<Description><![CDATA[Compared QImages differ in format. <Description><![CDATA[Compared QImages differ in format.
Actual (opA): 6 Actual (opA): 6
Expected (opB): 3]]></Description> Expected (opB): 3]]></Description>
</Incident> </Incident>
<Incident type="fail" file="tst_cmptest.cpp" line="392"> <Incident type="fail" file="tst_cmptest.cpp" line="403">
<DataTag><![CDATA[different pixels]]></DataTag> <DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description> <Description><![CDATA[Compared values are not the same]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="verify"> <TestFunction name="verify">
<Incident type="fail" file="tst_cmptest.cpp" line="404"> <Incident type="fail" file="tst_cmptest.cpp" line="415">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="verify2"> <TestFunction name="verify2">
<Incident type="fail" file="tst_cmptest.cpp" line="410"> <Incident type="fail" file="tst_cmptest.cpp" line="421">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="tryVerify"> <TestFunction name="tryVerify">
<Incident type="fail" file="tst_cmptest.cpp" line="416"> <Incident type="fail" file="tst_cmptest.cpp" line="427">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>
</TestFunction> </TestFunction>
<TestFunction name="tryVerify2"> <TestFunction name="tryVerify2">
<Incident type="fail" file="tst_cmptest.cpp" line="422"> <Incident type="fail" file="tst_cmptest.cpp" line="433">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
</Incident> </Incident>
<Duration msecs="0"/> <Duration msecs="0"/>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="0" failures="26" tests="16" name="tst_Cmptest"> <testsuite errors="0" failures="27" tests="17" name="tst_Cmptest">
<properties> <properties>
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
@ -14,6 +14,11 @@
Actual (Qt::ArrowCursor): ArrowCursor Actual (Qt::ArrowCursor): ArrowCursor
Expected (Qt::BusyCursor) : BusyCursor" result="fail"/> Expected (Qt::BusyCursor) : BusyCursor" result="fail"/>
</testcase> </testcase>
<testcase result="fail" name="compare_class_enums">
<failure message="Compared values are not the same
Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1
Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2" result="fail"/>
</testcase>
<testcase result="pass" name="compare_boolfuncs"/> <testcase result="pass" name="compare_boolfuncs"/>
<testcase result="pass" name="compare_pointerfuncs"/> <testcase result="pass" name="compare_pointerfuncs"/>
<testcase result="fail" name="compare_tostring"> <testcase result="fail" name="compare_tostring">