summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qstring
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-10-21 22:20:13 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-12-28 09:14:59 +0000
commit8f166ccf4081e624a8d23b21f236151c9dc38f28 (patch)
treef361878be2b3168670696d0cb07af9962b325b79 /tests/auto/corelib/tools/qstring
parent050b68241220a5b52c93e1f4cca3be5e71856357 (diff)
QString: add resize(int, QChar)
This will be used in QTextStream to speed up padding processing. [ChangeLog][QtCore][QString] Added resize(int, QChar) overload. Change-Id: Id51f8cdacb167310157100b05cacf20e9a5d2716 Reviewed-by: Topi Reiniƶ <topi.reinio@theqtcompany.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/corelib/tools/qstring')
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index f8a4d8a00a..3d5167d574 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -556,6 +556,7 @@ private slots:
void nanAndInf();
void compare_data();
void compare();
+ void resize();
void resizeAfterFromRawData();
void resizeAfterReserve();
void resizeWithNegative() const;
@@ -6013,6 +6014,22 @@ void tst_QString::compare()
}
}
+void tst_QString::resize()
+{
+ QString s = QLatin1String("hello world");
+
+ s.resize(5);
+ QCOMPARE(s, QLatin1String("hello"));
+ s.resize(8);
+ QCOMPARE(s.size(), 8);
+ QVERIFY(s.startsWith(QLatin1String("hello")));
+
+ s.resize(10, QLatin1Char('n'));
+ QCOMPARE(s.size(), 10);
+ QVERIFY(s.startsWith(QLatin1String("hello")));
+ QCOMPARE(s.right(2), QLatin1String("nn"));
+}
+
void tst_QString::resizeAfterFromRawData()
{
QString buffer("hello world");