From b36c6bab8db724a59f69e5205e031cccf4520ab7 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Thu, 7 Jul 2016 14:36:38 +0300 Subject: QString: add auto test for chop() Change-Id: I8fc65c65776a64cc92e8cba3993d17746be81ba1 Reviewed-by: Edward Welbourne --- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/auto/corelib/tools/qstring/tst_qstring.cpp') 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; -- cgit v1.2.3