summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-05-18 18:58:29 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-30 02:28:30 +0200
commit6276427438d8247348f3bc9643d915d725f229d8 (patch)
tree4ecd5ad231f74ff62cf0654122cc1ac31a8e7b50 /tests
parent7f324c4979bf83d68a18cbb4f8cd45752deb2e7c (diff)
QString::append: add (const QChar*, int len) overload
Both insert and replace have this overload, so one reason to add it to append(), too, is consistency. But I can also make good use of this overload in the the new QStringList::join(QChar) overload, so it's actually useful in its own right. Change-Id: Iccd48f9cb84831399e4db7e3e78eba25c0ced30d Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 7476fa0c38..3891a715f7 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -2012,9 +2012,29 @@ void tst_QString::insert()
void tst_QString::append()
{
- QString a;
- a = "<>ABCABCABCABC";
- QCOMPARE(a.append(">"),(QString)"<>ABCABCABCABC>");
+ {
+ QString a;
+ a = "<>ABCABCABCABC";
+ QCOMPARE(a.append(">"),QString("<>ABCABCABCABC>"));
+ }
+
+ {
+ QString a;
+ static const QChar unicode[] = { 'H', 'e', 'l', 'l', 'o', ',', ' ', 'W', 'o', 'r', 'l', 'd', '!' };
+ a.append(unicode, sizeof unicode / sizeof *unicode);
+ QCOMPARE(a, QLatin1String("Hello, World!"));
+ static const QChar nl('\n');
+ a.append(&nl, 1);
+ QCOMPARE(a, QLatin1String("Hello, World!\n"));
+ a.append(unicode, sizeof unicode / sizeof *unicode);
+ QCOMPARE(a, QLatin1String("Hello, World!\nHello, World!"));
+ a.append(unicode, 0); // no-op
+ QCOMPARE(a, QLatin1String("Hello, World!\nHello, World!"));
+ a.append(unicode, -1); // no-op
+ QCOMPARE(a, QLatin1String("Hello, World!\nHello, World!"));
+ a.append(0, 1); // no-op
+ QCOMPARE(a, QLatin1String("Hello, World!\nHello, World!"));
+ }
}
void tst_QString::append_bytearray_data()