From 9bc546e4920af554011adab10e15624f9a012bf8 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 13 Dec 2011 17:26:36 +1000 Subject: Add testlib selftest for QStringList comparison. The (disabled) alive selftest contained a test for the QStringList specialization of the QTest::qCompare template. This test is unrelated to the rest of the alive selftest, so move it to the cmptest selftest, where QCOMPARE is tested. Change-Id: Ic6f0e491dd3b3ce8b4ca1d49666a099815575eaa Reviewed-by: Rohan McGovern --- tests/auto/testlib/selftests/alive/tst_alive.cpp | 77 --------------------- .../auto/testlib/selftests/cmptest/tst_cmptest.cpp | 78 +++++++++++++++++++++- tests/auto/testlib/selftests/expected_alive.txt | 22 +----- .../testlib/selftests/expected_cmptest.lightxml | 27 ++++++++ tests/auto/testlib/selftests/expected_cmptest.txt | 22 +++++- tests/auto/testlib/selftests/expected_cmptest.xml | 27 ++++++++ .../testlib/selftests/expected_cmptest.xunitxml | 19 +++++- 7 files changed, 171 insertions(+), 101 deletions(-) (limited to 'tests/auto/testlib/selftests') diff --git a/tests/auto/testlib/selftests/alive/tst_alive.cpp b/tests/auto/testlib/selftests/alive/tst_alive.cpp index f29aebb176..93cea82c20 100644 --- a/tests/auto/testlib/selftests/alive/tst_alive.cpp +++ b/tests/auto/testlib/selftests/alive/tst_alive.cpp @@ -52,8 +52,6 @@ class tst_Alive: public QObject private slots: void alive(); void addMouseDClick() const; - void compareQStringLists() const; - void compareQStringLists_data() const; }; void tst_Alive::alive() @@ -95,80 +93,5 @@ void tst_Alive::addMouseDClick() const QVERIFY(listener.isTested); } -void tst_Alive::compareQStringLists() const -{ - QFETCH(QStringList, opA); - QFETCH(QStringList, opB); - - QCOMPARE(opA, opB); -} - -void tst_Alive::compareQStringLists_data() const -{ - QTest::addColumn("opA"); - QTest::addColumn("opB"); - - { - QStringList opA; - opA.append(QLatin1String("string1")); - opA.append(QLatin1String("string2")); - - QStringList opB(opA); - opA.append(QLatin1String("string3")); - opB.append(QLatin1String("DIFFERS")); - - QTest::newRow("") << opA << opB; - } - - { - QStringList opA; - opA.append(QLatin1String("string1")); - opA.append(QLatin1String("string2")); - - QStringList opB(opA); - opA.append(QLatin1String("string3")); - opA.append(QLatin1String("string4")); - - opB.append(QLatin1String("DIFFERS")); - opB.append(QLatin1String("string4")); - - QTest::newRow("") << opA << opB; - } - - { - QStringList opA; - opA.append(QLatin1String("string1")); - opA.append(QLatin1String("string2")); - - QStringList opB; - opB.append(QLatin1String("string1")); - - QTest::newRow("") << opA << opB; - } - - { - QStringList opA; - opA.append(QLatin1String("openInNewWindow")); - opA.append(QLatin1String("openInNewTab")); - opA.append(QLatin1String("separator")); - opA.append(QLatin1String("bookmark_add")); - opA.append(QLatin1String("savelinkas")); - opA.append(QLatin1String("copylinklocation")); - opA.append(QLatin1String("separator")); - opA.append(QLatin1String("openWith_submenu")); - opA.append(QLatin1String("preview1")); - opA.append(QLatin1String("actions_submenu")); - opA.append(QLatin1String("separator")); - opA.append(QLatin1String("viewDocumentSource")); - - QStringList opB; - opB.append(QLatin1String("viewDocumentSource")); - - QTest::newRow("") << opA << opB; - - QTest::newRow("") << opB << opA; - } -} - QTEST_MAIN(tst_Alive) #include "tst_alive.moc" diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index 70396a75b3..924b734e51 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -52,6 +52,8 @@ private slots: void compare_pointerfuncs(); void compare_tostring(); void compare_tostring_data(); + void compareQStringLists(); + void compareQStringLists_data(); }; static bool boolfunc() { return true; } @@ -126,6 +128,80 @@ void tst_Cmptest::compare_tostring() QCOMPARE(actual, expected); } -QTEST_MAIN(tst_Cmptest) +void tst_Cmptest::compareQStringLists_data() +{ + QTest::addColumn("opA"); + QTest::addColumn("opB"); + + { + QStringList opA; + opA.append(QLatin1String("string1")); + opA.append(QLatin1String("string2")); + + QStringList opB(opA); + opA.append(QLatin1String("string3")); + opB.append(QLatin1String("DIFFERS")); + + QTest::newRow("") << opA << opB; + } + + { + QStringList opA; + opA.append(QLatin1String("string1")); + opA.append(QLatin1String("string2")); + + QStringList opB(opA); + opA.append(QLatin1String("string3")); + opA.append(QLatin1String("string4")); + + opB.append(QLatin1String("DIFFERS")); + opB.append(QLatin1String("string4")); + + QTest::newRow("") << opA << opB; + } + + { + QStringList opA; + opA.append(QLatin1String("string1")); + opA.append(QLatin1String("string2")); + + QStringList opB; + opB.append(QLatin1String("string1")); + + QTest::newRow("") << opA << opB; + } + + { + QStringList opA; + opA.append(QLatin1String("openInNewWindow")); + opA.append(QLatin1String("openInNewTab")); + opA.append(QLatin1String("separator")); + opA.append(QLatin1String("bookmark_add")); + opA.append(QLatin1String("savelinkas")); + opA.append(QLatin1String("copylinklocation")); + opA.append(QLatin1String("separator")); + opA.append(QLatin1String("openWith_submenu")); + opA.append(QLatin1String("preview1")); + opA.append(QLatin1String("actions_submenu")); + opA.append(QLatin1String("separator")); + opA.append(QLatin1String("viewDocumentSource")); + + QStringList opB; + opB.append(QLatin1String("viewDocumentSource")); + + QTest::newRow("") << opA << opB; + + QTest::newRow("") << opB << opA; + } +} + +void tst_Cmptest::compareQStringLists() +{ + QFETCH(QStringList, opA); + QFETCH(QStringList, opB); + + QCOMPARE(opA, opB); +} +QTEST_MAIN(tst_Cmptest) #include "tst_cmptest.moc" diff --git a/tests/auto/testlib/selftests/expected_alive.txt b/tests/auto/testlib/selftests/expected_alive.txt index 74d93c5a21..352c878575 100644 --- a/tests/auto/testlib/selftests/expected_alive.txt +++ b/tests/auto/testlib/selftests/expected_alive.txt @@ -8,26 +8,6 @@ QWARN : tst_Alive::alive() TEST LAGS 3 PINGS behind! QWARN : tst_Alive::alive() TEST LAGS 4 PINGS behind! PASS : tst_Alive::alive() PASS : tst_Alive::addMouseDClick() -FAIL! : tst_Alive::compareQStringLists() Compared QStringLists differ at index 2. - Actual (opA) : 'string3' - Expected (opB) : 'DIFFERS' - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/alive/tst_alive.cpp(68)] -FAIL! : tst_Alive::compareQStringLists() Compared QStringLists differ at index 2. - Actual (opA) : 'string3' - Expected (opB) : 'DIFFERS' - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/alive/tst_alive.cpp(68)] -FAIL! : tst_Alive::compareQStringLists() Compared QStringLists have different sizes. - Actual (opA) size : '2' - Expected (opB) size: '1' - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/alive/tst_alive.cpp(68)] -FAIL! : tst_Alive::compareQStringLists() Compared QStringLists have different sizes. - Actual (opA) size : '12' - Expected (opB) size: '1' - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/alive/tst_alive.cpp(68)] -FAIL! : tst_Alive::compareQStringLists() Compared QStringLists have different sizes. - Actual (opA) size : '1' - Expected (opB) size: '12' - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/alive/tst_alive.cpp(68)] PASS : tst_Alive::cleanupTestCase() -Totals: 4 passed, 5 failed, 0 skipped +Totals: 4 passed, 0 failed, 0 skipped ********* Finished testing of tst_Alive ********* diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml index 97b0621f9c..7aa4fe1f2f 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.lightxml +++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml @@ -37,6 +37,33 @@ Expected (expected): QVariant(PhonyClass,)]]> + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt index 30cc201ef1..3e40b3be7a 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.txt +++ b/tests/auto/testlib/selftests/expected_cmptest.txt @@ -19,6 +19,26 @@ FAIL! : tst_Cmptest::compare_tostring(both non-null user type) Compared values Actual (actual): QVariant(PhonyClass,) Expected (expected): QVariant(PhonyClass,) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(122)] +FAIL! : tst_Cmptest::compareQStringLists() Compared QStringLists differ at index 2. + Actual (opA) : 'string3' + Expected (opB) : 'DIFFERS' + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/alive/tst_alive.cpp(68)] +FAIL! : tst_Cmptest::compareQStringLists() Compared QStringLists differ at index 2. + Actual (opA) : 'string3' + Expected (opB) : 'DIFFERS' + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/alive/tst_alive.cpp(68)] +FAIL! : tst_Cmptest::compareQStringLists() Compared QStringLists have different sizes. + Actual (opA) size : '2' + Expected (opB) size: '1' + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/alive/tst_alive.cpp(68)] +FAIL! : tst_Cmptest::compareQStringLists() Compared QStringLists have different sizes. + Actual (opA) size : '12' + Expected (opB) size: '1' + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/alive/tst_alive.cpp(68)] +FAIL! : tst_Cmptest::compareQStringLists() Compared QStringLists have different sizes. + Actual (opA) size : '1' + Expected (opB) size: '12' + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/alive/tst_alive.cpp(68)] PASS : tst_Cmptest::cleanupTestCase() -Totals: 4 passed, 4 failed, 0 skipped +Totals: 4 passed, 9 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 ea05c725fd..1b32389acb 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xml +++ b/tests/auto/testlib/selftests/expected_cmptest.xml @@ -39,6 +39,33 @@ Expected (expected): QVariant(PhonyClass,)]]> + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml index 01bfda8d01..8ce2dc92d5 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml +++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml @@ -1,5 +1,5 @@ - + @@ -21,6 +21,23 @@ Actual (actual): QVariant(PhonyClass,<value not representable as string>) Expected (expected): QVariant(PhonyClass,<value not representable as string>)" result="fail"/> + + + + + + + -- cgit v1.2.3