summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Buhr <andreas.buhr@qt.io>2020-11-19 13:17:31 +0100
committerAndreas Buhr <andreas.buhr@qt.io>2020-11-19 23:56:15 +0100
commit06f58a909bcdcd08d125f5decd1fba894c285765 (patch)
tree0d7c31dd1b9ac291eac69c7dbec831d4413d1530
parentebaae45ea17efc230209ed90d94596647cf6cb48 (diff)
Add unit test for QString::replace with out-of-bounds position
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 <marten.nordheim@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
-rw-r--r--tests/auto/corelib/text/qstring/tst_qstring.cpp10
1 files changed, 10 insertions, 0 deletions
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()