From d1da83002d18040f8ac21ebf6542ff71cb462509 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 25 Jul 2023 19:08:50 +0300 Subject: [PATCH] QByteArray: remove a unittest It relied on an implementation detail of operator+=(), that the latter wouldn't just use assignement (e.g. if `this` is empty/null). It also had undefined behavior, when the char array used with fromRawData() went out of, the nested, scope, the code was pointing to a dangling stack pointer. Thanks to Thiago for the explanation in code review. This ties in with further changes in this series, where append() is changed to preserve null-ness; there is no way to preserve null-ness in append() while keeping this unittest passing. Change-Id: I43b9f60db9ce2d471f359f32bcc48e7b4cfceeab Reviewed-by: Thiago Macieira --- .../auto/corelib/text/qbytearray/tst_qbytearray.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp index 890cb8a565..bc84e25651 100644 --- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp @@ -78,7 +78,6 @@ private slots: void blockSizeCalculations(); void resizeAfterFromRawData(); - void appendAfterFromRawData(); void toFromHex_data(); void toFromHex(); void toFromPercentEncoding(); @@ -1670,17 +1669,6 @@ void tst_QByteArray::resizeAfterFromRawData() QVERIFY(array.constData()[5] == 0); } -void tst_QByteArray::appendAfterFromRawData() -{ - QByteArray arr; - { - char data[] = "X"; - arr += QByteArray::fromRawData(data, sizeof(data)); - data[0] = 'Y'; - } - QCOMPARE(arr.at(0), 'X'); -} - void tst_QByteArray::toFromHex_data() { QTest::addColumn("str");