From e4682408b036b95d4edfb7e324c8e6835230d263 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 2 Jun 2023 08:44:29 +0200 Subject: [PATCH] Add tst_QString::prependEventuallyProducesFreeSpaceAtBegin() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This seems to work with prepend(char), but not with prepend("data"), cf. QTBUG-114167. Task-number: QTBUG-114167 Pick-to: 6.5 6.6 Change-Id: I7aa4dca7c2b5938c2e5ad416231945c23140d659 Reviewed-by: MÃ¥rten Nordheim --- tests/auto/corelib/text/qstring/tst_qstring.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index a99b354b95..a6362d6a23 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -430,6 +430,8 @@ private slots: void prepend_char_data() { prepend_data({EmptyIsNoop, Latin1Encoded}); } #endif + void prependEventuallyProducesFreeSpaceAtBegin(); + void append_qstring() { append_impl(); } void append_qstring_data() { append_data(); } void append_qstringview() { append_impl(); } @@ -3710,6 +3712,14 @@ void tst_QString::prepend_bytearray_special_cases() } #endif // !defined(QT_RESTRICTED_CAST_FROM_ASCII) && !defined(QT_NO_CAST_FROM_ASCII) +void tst_QString::prependEventuallyProducesFreeSpaceAtBegin() +{ + QString s; + for (int i = 0; i < 100 && !s.data_ptr().freeSpaceAtBegin(); ++i) + s.prepend(u'd'); + QCOMPARE_GT(s.data_ptr().freeSpaceAtBegin(), 1); +} + void tst_QString::replace_uint_uint() { QFETCH( QString, string );