summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qstring
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-07-08 11:27:50 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-07-11 13:22:46 +0000
commite27c07389bcf8b6c5cc1c356a3ee1759045270a8 (patch)
treeccfdc0b996d3779ce8f3c89a45a10f183ddabb45 /tests/auto/corelib/tools/qstring
parenta0bb2fc4061a91edab8222158fd88454f40dab27 (diff)
QString: adapt chop() auto test as data-driven test
Thiago Macieira asked to do that. Change-Id: I9a07dad7ff2bfebc2f863e0e9f151aab66450bcf Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/tools/qstring')
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 601987086d..3bacf5d942 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -482,6 +482,7 @@ private slots:
void sprintf();
void fill();
void truncate();
+ void chop_data();
void chop();
void constructor();
void constructorQByteArray_data();
@@ -1222,29 +1223,29 @@ void tst_QString::truncate()
}
-void tst_QString::chop()
+void tst_QString::chop_data()
{
- const QString original("abcd");
-
- QString str = original;
- str.chop(1);
- QCOMPARE(str, QLatin1String("abc"));
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<int>("count" );
+ QTest::addColumn<QString>("result");
- str = original;
- str.chop(0);
- QCOMPARE(str, original);
+ const QString original("abcd");
- str = original;
- str.chop(-1);
- QCOMPARE(str, original);
+ QTest::newRow("data0") << original << 1 << QString("abc");
+ QTest::newRow("data1") << original << 0 << original;
+ QTest::newRow("data2") << original << -1 << original;
+ QTest::newRow("data3") << original << original.size() << QString();
+ QTest::newRow("data4") << original << 1000 << QString();
+}
- str = original;
- str.chop(original.size());
- QVERIFY(str.isEmpty());
+void tst_QString::chop()
+{
+ QFETCH(QString, input);
+ QFETCH(int, count);
+ QFETCH(QString, result);
- str = original;
- str.chop(1000);
- QVERIFY(str.isEmpty());
+ input.chop(count);
+ QCOMPARE(input, result);
}
void tst_QString::fill()