From 06f58a909bcdcd08d125f5decd1fba894c285765 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Thu, 19 Nov 2020 13:17:31 +0100 Subject: Add unit test for QString::replace with out-of-bounds position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QString::replace(pos, len, *unicode, size) can handle positions which are outside of the this-string. In that case, it is a no-op. Coverage analysis revealed we do not have a unit test for this. This patch adds one. Change-Id: Id4a407e860fff0d5c7c0a200c379e5e3961c86d2 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Jarek Kobus --- tests/auto/corelib/text/qstring/tst_qstring.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index e6d73c6ef1..ab118deb90 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -2748,6 +2748,16 @@ void tst_QString::replace_uint_uint_extra() s.replace( 0, 3, smallReplacement ); QCOMPARE( s, smallReplacement ); } + + { + QString s; + s.insert(0, QLatin1String("BBB")); + + auto smallReplacement = QString("C"); + + s.replace( 5, 3, smallReplacement ); + QCOMPARE( s, QLatin1String("BBB") ); + } } void tst_QString::replace_extra() -- cgit v1.2.3