From e01b1634048ebf5858b77f2a6541a960babe232c Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 19 Jan 2013 11:52:03 +0100 Subject: QTestLib: improve output when comparing lists fails. Only QStringList was handled before, now any QList is handled. A specialization for QStringList is still needed though, due to the way template matching works. Example with QList. Before: FAIL! : tst_QTextCodec::threadSafety() Compared values are not the same Loc: [../tst_qtextcodec.cpp(2057)] After: FAIL! : tst_QTextCodec::threadSafety() Compared lists differ at index 0. Actual (res2.toList()): '0' Expected (mibList): '3' Loc: [../tst_qtextcodec.cpp(2057)] Change-Id: If0fdec3236ddb78a679ee549aba569ef5571c395 Reviewed-by: Jason McDonald Reviewed-by: Friedemann Kleint --- .../auto/testlib/selftests/cmptest/tst_cmptest.cpp | 16 +++++++++++++++ .../testlib/selftests/expected_cmptest.lightxml | 24 +++++++++++++++++----- tests/auto/testlib/selftests/expected_cmptest.txt | 20 ++++++++++++------ tests/auto/testlib/selftests/expected_cmptest.xml | 24 +++++++++++++++++----- .../testlib/selftests/expected_cmptest.xunitxml | 22 ++++++++++++++------ 5 files changed, 84 insertions(+), 22 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index 572388df6c..7213d9a82d 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -136,6 +136,8 @@ private slots: void compare_tostring_data(); void compareQStringLists(); void compareQStringLists_data(); + void compareQListInt(); + void compareQListDouble(); void compareQPixmaps(); void compareQPixmaps_data(); void compareQImages(); @@ -307,6 +309,20 @@ void tst_Cmptest::compareQStringLists() QCOMPARE(opA, opB); } +void tst_Cmptest::compareQListInt() +{ + QList int1; int1 << 1 << 2 << 3; + QList int2; int2 << 1 << 2 << 4; + QCOMPARE(int1, int2); +} + +void tst_Cmptest::compareQListDouble() +{ + QList double1; double1 << 1.5 << 2 << 3; + QList double2; double2 << 1 << 2 << 4; + QCOMPARE(double1, double2); +} + void tst_Cmptest::compareQPixmaps_data() { QTest::addColumn("opA"); diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml index 83b2e6e137..54c5bb85f0 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.lightxml +++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml @@ -49,35 +49,49 @@ - - - - - + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt index de666ed8b1..d41da53b06 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.txt +++ b/tests/auto/testlib/selftests/expected_cmptest.txt @@ -22,26 +22,34 @@ FAIL! : tst_Cmptest::compare_tostring(both non-null user type) Compared values Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(214)] PASS : tst_Cmptest::compareQStringLists(empty lists) PASS : tst_Cmptest::compareQStringLists(equal lists) -FAIL! : tst_Cmptest::compareQStringLists(last item different) Compared QStringLists differ at index 2. +FAIL! : tst_Cmptest::compareQStringLists(last item different) Compared lists differ at index 2. Actual (opA): 'string3' Expected (opB): 'DIFFERS' Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(308)] -FAIL! : tst_Cmptest::compareQStringLists(second-last item different) Compared QStringLists differ at index 2. +FAIL! : tst_Cmptest::compareQStringLists(second-last item different) Compared lists differ at index 2. Actual (opA): 'string3' Expected (opB): 'DIFFERS' Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(308)] -FAIL! : tst_Cmptest::compareQStringLists(prefix) Compared QStringLists have different sizes. +FAIL! : tst_Cmptest::compareQStringLists(prefix) Compared lists have different sizes. Actual (opA) size: '2' Expected (opB) size: '1' Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(308)] -FAIL! : tst_Cmptest::compareQStringLists(short list second) Compared QStringLists have different sizes. +FAIL! : tst_Cmptest::compareQStringLists(short list second) Compared lists have different sizes. Actual (opA) size: '12' Expected (opB) size: '1' Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(308)] -FAIL! : tst_Cmptest::compareQStringLists(short list first) Compared QStringLists have different sizes. +FAIL! : tst_Cmptest::compareQStringLists(short list first) Compared lists have different sizes. Actual (opA) size: '1' Expected (opB) size: '12' Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(308)] +FAIL! : tst_Cmptest::compareQListInt() Compared lists differ at index 2. + Actual (int1): '3' + Expected (int2): '4' + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(316)] +FAIL! : tst_Cmptest::compareQListDouble() Compared lists differ at index 0. + Actual (double1): '1.5' + Expected (double2): '1' + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(323)] PASS : tst_Cmptest::compareQPixmaps(both null) FAIL! : tst_Cmptest::compareQPixmaps(one null) Compared QPixmaps differ. Actual (opA).isNull(): 1 @@ -79,5 +87,5 @@ FAIL! : tst_Cmptest::compareQImages(different format) Compared QImages differ i FAIL! : tst_Cmptest::compareQImages(different pixels) Compared values are not the same Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(360)] PASS : tst_Cmptest::cleanupTestCase() -Totals: 11 passed, 18 failed, 0 skipped +Totals: 11 passed, 20 failed, 0 skipped ********* Finished testing of tst_Cmptest ********* diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml index 0e5b6de335..ccab93d7c0 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xml +++ b/tests/auto/testlib/selftests/expected_cmptest.xml @@ -51,35 +51,49 @@ - - - - - + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml index 33e78a5290..0cb88147b0 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml +++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml @@ -1,5 +1,5 @@ - + @@ -22,22 +22,32 @@ Expected (expected): QVariant(PhonyClass,<value not representable as string>)" result="fail"/> - - - - - + + + + + +