diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2015-03-04 09:33:42 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-03-07 19:36:24 +0000 |
commit | 53ce0d1a31c8ebb54952887b8bcf769843d50d9c (patch) | |
tree | 599da5178c8ede0d80dc30ca6c24cd79f1699534 /tests/auto/corelib/tools/qstring | |
parent | a8c74ddcf78604c9038ba2a2bea81e445e4b3c58 (diff) |
QStringAlgorithms::simplified_helper: add missing check for detached
Otherwise, we modify shared strings that happened to be rvalues.
Task-number: QTBUG-44706
Change-Id: Ia0aac2f09e9245339951ffff13c85bfc912f03d1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'tests/auto/corelib/tools/qstring')
-rw-r--r-- | tests/auto/corelib/tools/qstring/tst_qstring.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 52c3e65a24..8cd9610542 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -2040,6 +2040,9 @@ void tst_QString::simplified() QFETCH(QString, full); QFETCH(QString, simple); + QString orig_full = full; + orig_full.data(); // forces a detach + QString result = full.simplified(); if (simple.isNull()) { QVERIFY2(result.isNull(), qPrintable("'" + full + "' did not yield null: " + result)); @@ -2048,6 +2051,12 @@ void tst_QString::simplified() } else { QCOMPARE(result, simple); } + QCOMPARE(full, orig_full); + + // without detaching: + QString copy1 = full; + QCOMPARE(qMove(full).simplified(), simple); + QCOMPARE(full, orig_full); // force a detach if (!full.isEmpty()) |