From f925278917a9f5db94755b9dc57310e4e8b9d159 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 (cherry picked from commit d1da83002d18040f8ac21ebf6542ff71cb462509) --- .../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 617737d9ed9..084fb5c0e53 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(); @@ -1668,17 +1667,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");