From 2f05aa82e792089a249a0a77f1ae7e055cc90208 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 20 May 2020 13:09:21 +0200 Subject: Adjust resize() behavior of QString and QByteArray to match Qt 5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Thiago Macieira Reviewed-by: MÃ¥rten Nordheim --- tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp') diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp index 67259c04dc..e90f4ff14e 100644 --- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp @@ -1606,7 +1606,9 @@ void tst_QByteArray::resizeAfterFromRawData() QByteArray array = QByteArray::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_QByteArray::appendAfterFromRawData() -- cgit v1.2.3