diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2015-11-02 16:06:49 -0500 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-11-18 00:30:40 +0000 |
commit | f29b6943f0a3b535309a383c41711de05f22eb54 (patch) | |
tree | 804d1cd4a3e31797e81481ddff382ff53c863701 /tests/auto | |
parent | 7c05a0cc9904e7a42c20e0b7751082f7f812e28d (diff) |
QString: Fix in-place toUpper/Lower when there's size expansion
When that happens, we need to detach (in-place conversion won't work),
so we recurse back into the same function, but the template version that
does detaching.
Task-number: QTBUG-49181
Change-Id: Idba8c29717f34c70a58fffff1412fea3acc95f98
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/tools/qstring/tst_qstring.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index d18aa9f5f3..cc9f250be9 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -2144,6 +2144,22 @@ void tst_QString::toUpper() QCOMPARE( QString("`abyz{").toUpper(), QString("`ABYZ{")); QCOMPARE( QString(1, QChar(0xdf)).toUpper(), QString("SS")); + { + QString s = QString::fromUtf8("Gro\xc3\x9fstra\xc3\x9f""e"); + + // call lvalue-ref version, mustn't change the original + QCOMPARE(s.toUpper(), QString("GROSSSTRASSE")); + QCOMPARE(s, QString::fromUtf8("Gro\xc3\x9fstra\xc3\x9f""e")); + + // call rvalue-ref while shared (the original mustn't change) + QString copy = s; + QCOMPARE(qMove(copy).toUpper(), QString("GROSSSTRASSE")); + QCOMPARE(s, QString::fromUtf8("Gro\xc3\x9fstra\xc3\x9f""e")); + + // call rvalue-ref version on detached case + copy.clear(); + QCOMPARE(qMove(s).toUpper(), QString("GROSSSTRASSE")); + } QString lower, upper; lower += QChar(QChar::highSurrogate(0x10428)); |