Add testlib selftest for QStringList comparison.
authorJason McDonald <jason.mcdonald@nokia.com>
Tue, 13 Dec 2011 07:26:36 +0000 (17:26 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 14 Dec 2011 01:40:17 +0000 (02:40 +0100)
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 <rohan.mcgovern@nokia.com>
tests/auto/testlib/selftests/alive/tst_alive.cpp
tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
tests/auto/testlib/selftests/expected_alive.txt
tests/auto/testlib/selftests/expected_cmptest.lightxml
tests/auto/testlib/selftests/expected_cmptest.txt
tests/auto/testlib/selftests/expected_cmptest.xml
tests/auto/testlib/selftests/expected_cmptest.xunitxml

index f29aebb..93cea82 100644 (file)
@@ -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<QStringList>("opA");
-    QTest::addColumn<QStringList>("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"
index 70396a7..924b734 100644 (file)
@@ -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<QStringList>("opA");
+    QTest::addColumn<QStringList>("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"
index 74d93c5..352c878 100644 (file)
@@ -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 *********
index 97b0621..7aa4fe1 100644 (file)
    Expected (expected): QVariant(PhonyClass,<value not representable as string>)]]></Description>
 </Incident>
 </TestFunction>
+<TestFunction name="compareQStringLists">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="203">
+    <Description><![CDATA[Compared QStringLists differ at index 2.
+   Actual (opA) : 'string3'
+   Expected (opB) : 'DIFFERS']]></Description>
+</Incident>
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="203">
+    <Description><![CDATA[Compared QStringLists differ at index 2.
+   Actual (opA) : 'string3'
+   Expected (opB) : 'DIFFERS']]></Description>
+</Incident>
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="203">
+    <Description><![CDATA[Compared QStringLists have different sizes.
+   Actual (opA) size  : '2'
+   Expected (opB) size: '1']]></Description>
+</Incident>
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="203">
+    <Description><![CDATA[Compared QStringLists have different sizes.
+   Actual (opA) size  : '12'
+   Expected (opB) size: '1']]></Description>
+</Incident>
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="203">
+    <Description><![CDATA[Compared QStringLists have different sizes.
+   Actual (opA) size  : '1'
+   Expected (opB) size: '12']]></Description>
+</Incident>
+</TestFunction>
 <TestFunction name="cleanupTestCase">
 <Incident type="pass" file="" line="0" />
 </TestFunction>
index 30cc201..3e40b3b 100644 (file)
@@ -19,6 +19,26 @@ FAIL!  : tst_Cmptest::compare_tostring(both non-null user type) Compared values
    Actual (actual): QVariant(PhonyClass,<value not representable as string>)
    Expected (expected): QVariant(PhonyClass,<value not representable as string>)
    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 *********
index ea05c72..1b32389 100644 (file)
    Expected (expected): QVariant(PhonyClass,<value not representable as string>)]]></Description>
 </Incident>
 </TestFunction>
+<TestFunction name="compareQStringLists">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="203">
+    <Description><![CDATA[Compared QStringLists differ at index 2.
+   Actual (opA) : 'string3'
+   Expected (opB) : 'DIFFERS']]></Description>
+</Incident>
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="203">
+    <Description><![CDATA[Compared QStringLists differ at index 2.
+   Actual (opA) : 'string3'
+   Expected (opB) : 'DIFFERS']]></Description>
+</Incident>
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="203">
+    <Description><![CDATA[Compared QStringLists have different sizes.
+   Actual (opA) size  : '2'
+   Expected (opB) size: '1']]></Description>
+</Incident>
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="203">
+    <Description><![CDATA[Compared QStringLists have different sizes.
+   Actual (opA) size  : '12'
+   Expected (opB) size: '1']]></Description>
+</Incident>
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="203">
+    <Description><![CDATA[Compared QStringLists have different sizes.
+   Actual (opA) size  : '1'
+   Expected (opB) size: '12']]></Description>
+</Incident>
+</TestFunction>
 <TestFunction name="cleanupTestCase">
 <Incident type="pass" file="" line="0" />
 </TestFunction>
index 01bfda8..8ce2dc9 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<testsuite errors="0" failures="4" tests="5" name="tst_Cmptest">
+<testsuite errors="0" failures="9" tests="6" name="tst_Cmptest">
   <properties>
     <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
     <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
    Actual (actual): QVariant(PhonyClass,&lt;value not representable as string&gt;)
    Expected (expected): QVariant(PhonyClass,&lt;value not representable as string&gt;)" result="fail"/>
   </testcase>
+  <testcase result="fail" name="compareQStringLists">
+    <failure message="Compared QStringLists differ at index 2.
+   Actual (opA) : &apos;string3&apos;
+   Expected (opB) : &apos;DIFFERS&apos;" result="fail"/>
+    <failure message="Compared QStringLists differ at index 2.
+   Actual (opA) : &apos;string3&apos;
+   Expected (opB) : &apos;DIFFERS&apos;" result="fail"/>
+    <failure message="Compared QStringLists have different sizes.
+   Actual (opA) size  : &apos;2&apos;
+   Expected (opB) size: &apos;1&apos;" result="fail"/>
+    <failure message="Compared QStringLists have different sizes.
+   Actual (opA) size  : &apos;12&apos;
+   Expected (opB) size: &apos;1&apos;" result="fail"/>
+    <failure message="Compared QStringLists have different sizes.
+   Actual (opA) size  : &apos;1&apos;
+   Expected (opB) size: &apos;12&apos;" result="fail"/>
+  </testcase>
   <testcase result="pass" name="cleanupTestCase"/>
   <system-err/>
 </testsuite>