summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-12-13 17:26:36 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-14 02:40:17 +0100
commit9bc546e4920af554011adab10e15624f9a012bf8 (patch)
tree1f6265350fc9680ab35169be10a82b09a41a53cb /tests/auto/testlib
parenta9ad8886fe25276ea6e81e191392d4c90d207759 (diff)
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 <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/testlib')
-rw-r--r--tests/auto/testlib/selftests/alive/tst_alive.cpp77
-rw-r--r--tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp78
-rw-r--r--tests/auto/testlib/selftests/expected_alive.txt22
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.lightxml27
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.txt22
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xml27
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xunitxml19
7 files changed, 171 insertions, 101 deletions
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<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"
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<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"
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,<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>
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,<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 *********
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,<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>
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 @@
<?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"/>
@@ -21,6 +21,23 @@
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>