summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qbytearray
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2022-10-29 14:43:47 +0200
committerAhmad Samir <a.samirh78@gmail.com>2022-11-04 03:06:29 +0200
commit358b7a9e747549f85c1d1631dfb21210b52b36f5 (patch)
treee0ae16d076f4c3fde88f2a1644a981529f528208 /tests/auto/corelib/text/qbytearray
parent71c3aab7baae9220b37178711a49746f66975d63 (diff)
QByteArray: don't detach in remove()
- If this bytearray isn't shared call d->erase() as needed - if it's shared, instead of detaching, create a new bytearray, and copy all characters except for the ones that would be removed See task for details. Adjust unittest to test both code paths. Task-number: QTBUG-106182 Change-Id: I806e4d1707004345a2472e056905fbf675f765ab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/text/qbytearray')
-rw-r--r--tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
index 60bddc20df..e72d21ed0a 100644
--- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
@@ -1258,7 +1258,14 @@ void tst_QByteArray::remove()
QFETCH(int, position);
QFETCH(int, length);
QFETCH(QByteArray, expected);
- QCOMPARE(src.remove(position, length), expected);
+ // Test when it's shared
+ QByteArray ba1 = src;
+ QCOMPARE(ba1.remove(position, length), expected);
+
+ // Test when it's not shared
+ QByteArray ba2 = src;
+ ba2.detach();
+ QCOMPARE(ba2.remove(position, length), expected);
}
void tst_QByteArray::removeIf()