diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-03-28 08:57:11 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-31 22:54:14 +0200 |
commit | 08b8f9d0872cc68e90599c6896f3bef113f7b764 (patch) | |
tree | 35b0c667a0defff6195fd7d8f4f3feac8da1edd9 /tests/auto/corelib/tools/qstringlist | |
parent | 35ed65b1a94ae7c3788b9326775807bef31b0f69 (diff) |
tst_QStringList: add more checks for removeDuplicates
Check whether a detach happened, and also check that non-consecutive duplicates
are properly removed.
Change-Id: Iac7a3d8fe5ed5a69a9a0b55ddbf95308f11122c2
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/corelib/tools/qstringlist')
-rw-r--r-- | tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp index a9ddb6844e..d5506f3391 100644 --- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp +++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp @@ -296,9 +296,11 @@ void tst_QStringList::removeDuplicates_data() QTest::addColumn<QString>("before"); QTest::addColumn<QString>("after"); QTest::addColumn<int>("count"); + QTest::addColumn<bool>("detached"); - QTest::newRow("empty-1") << "Hello,Hello" << "Hello" << 1; - QTest::newRow("empty-2") << "Hello,World" << "Hello,World" << 0; + QTest::newRow("empty-1") << "Hello,Hello" << "Hello" << 1 << true; + QTest::newRow("empty-2") << "Hello,World" << "Hello,World" << 0 << false; + QTest::newRow("middle") << "Hello,World,Hello" << "Hello,World" << 1 << true; } void tst_QStringList::removeDuplicates() @@ -306,13 +308,16 @@ void tst_QStringList::removeDuplicates() QFETCH(QString, before); QFETCH(QString, after); QFETCH(int, count); + QFETCH(bool, detached); QStringList lbefore = before.split(','); + const QStringList oldlbefore = lbefore; QStringList lafter = after.split(','); int removed = lbefore.removeDuplicates(); QCOMPARE(removed, count); QCOMPARE(lbefore, lafter); + QCOMPARE(detached, !oldlbefore.isSharedWith(lbefore)); } void tst_QStringList::streamingOperator() |