summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qstring
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-07-07 14:36:38 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-07-07 15:03:30 +0000
commitb36c6bab8db724a59f69e5205e031cccf4520ab7 (patch)
treef7052670bf05910226859683fbdd793e282a0caf /tests/auto/corelib/tools/qstring
parentb6c10cf33107309f13c9845495d9d7d4f45f34bf (diff)
QString: add auto test for chop()
Change-Id: I8fc65c65776a64cc92e8cba3993d17746be81ba1 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/corelib/tools/qstring')
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index a922e3ad27..601987086d 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();
void constructor();
void constructorQByteArray_data();
void constructorQByteArray();
@@ -1221,6 +1222,31 @@ void tst_QString::truncate()
}
+void tst_QString::chop()
+{
+ const QString original("abcd");
+
+ QString str = original;
+ str.chop(1);
+ QCOMPARE(str, QLatin1String("abc"));
+
+ str = original;
+ str.chop(0);
+ QCOMPARE(str, original);
+
+ str = original;
+ str.chop(-1);
+ QCOMPARE(str, original);
+
+ str = original;
+ str.chop(original.size());
+ QVERIFY(str.isEmpty());
+
+ str = original;
+ str.chop(1000);
+ QVERIFY(str.isEmpty());
+}
+
void tst_QString::fill()
{
QString e;