summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;