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>
This commit is contained in:
parent
a9ad8886fe
commit
9bc546e492
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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 *********
|
||||
|
@ -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>
|
||||
|
@ -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 *********
|
||||
|
@ -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>
|
||||
|
@ -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,<value not representable as string>)
|
||||
Expected (expected): QVariant(PhonyClass,<value not representable as string>)" result="fail"/>
|
||||
</testcase>
|
||||
<testcase result="fail" name="compareQStringLists">
|
||||
<failure message="Compared QStringLists differ at index 2.
|
||||
Actual (opA) : 'string3'
|
||||
Expected (opB) : 'DIFFERS'" result="fail"/>
|
||||
<failure message="Compared QStringLists differ at index 2.
|
||||
Actual (opA) : 'string3'
|
||||
Expected (opB) : 'DIFFERS'" result="fail"/>
|
||||
<failure message="Compared QStringLists have different sizes.
|
||||
Actual (opA) size : '2'
|
||||
Expected (opB) size: '1'" result="fail"/>
|
||||
<failure message="Compared QStringLists have different sizes.
|
||||
Actual (opA) size : '12'
|
||||
Expected (opB) size: '1'" result="fail"/>
|
||||
<failure message="Compared QStringLists have different sizes.
|
||||
Actual (opA) size : '1'
|
||||
Expected (opB) size: '12'" result="fail"/>
|
||||
</testcase>
|
||||
<testcase result="pass" name="cleanupTestCase"/>
|
||||
<system-err/>
|
||||
</testsuite>
|
||||
|
Loading…
Reference in New Issue
Block a user