diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-05-20 13:09:21 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-05-21 17:59:31 +0200 |
commit | 2f05aa82e792089a249a0a77f1ae7e055cc90208 (patch) | |
tree | fd5a020d13d521d9205c5ac02d852e9a57476cfb /tests/auto/corelib/text/qstring/tst_qstring.cpp | |
parent | 42024666a37ad0e8b5c557a2fd901779f63d1fcb (diff) |
Adjust resize() behavior of QString and QByteArray to match Qt 5
resize() to a smaller size does not reallocate in Qt 5 if the container
is not shared. Match this here.
As a drive-by also fix resize calls on raw data strings to ensure
they are null terminated after the resize.
Change-Id: Ic4d8830e86ed3f247020d7ece3217cebd344ae96
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/corelib/text/qstring/tst_qstring.cpp')
-rw-r--r-- | tests/auto/corelib/text/qstring/tst_qstring.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 38df331cc2..ef93c732ac 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -6238,7 +6238,9 @@ void tst_QString::resizeAfterFromRawData() QString array = QString::fromRawData(buffer.constData(), buffer.size()); QVERIFY(array.constData() == buffer.constData()); array.resize(5); - QVERIFY(array.constData() == buffer.constData()); + QVERIFY(array.constData() != buffer.constData()); + // check null termination + QVERIFY(array.constData()[5] == 0); } void tst_QString::resizeAfterReserve() |