summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qstring/tst_qstring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/tools/qstring/tst_qstring.cpp')
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp9
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 5655d9f529..d9d6b985b7 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -4277,14 +4277,23 @@ void tst_QString::capacity()
QVERIFY( (int)s2.capacity() >= res );
QCOMPARE( s2, s1 );
+ s2 = s1; // share again
s2.reserve( res * 2 );
QVERIFY( (int)s2.capacity() >= res * 2 );
+ QVERIFY(s2.constData() != s1.constData());
QCOMPARE( s2, s1 );
+ // don't share again -- s2 must be detached for squeeze() to do anything
s2.squeeze();
QVERIFY( (int)s2.capacity() == res );
QCOMPARE( s2, s1 );
+ s2 = s1; // share again
+ int oldsize = s1.size();
+ s2.reserve( res / 2 );
+ QVERIFY( (int)s2.capacity() >= res / 2 );
+ QVERIFY( (int)s2.capacity() >= oldsize );
+ QCOMPARE( s2, s1 );
}
void tst_QString::section_data()