Add tst_QString::prependEventuallyProducesFreeSpaceAtBegin()

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 <marten.nordheim@qt.io>
This commit is contained in:
Marc Mutz 2023-06-02 08:44:29 +02:00
parent f1011bd2ed
commit e4682408b0

View File

@ -430,6 +430,8 @@ private slots:
void prepend_char_data() { prepend_data({EmptyIsNoop, Latin1Encoded}); }
#endif
void prependEventuallyProducesFreeSpaceAtBegin();
void append_qstring() { append_impl<QString>(); }
void append_qstring_data() { append_data(); }
void append_qstringview() { append_impl<QStringView, QString &(QString::*)(QStringView)>(); }
@ -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 );