diff options
author | Andreas Buhr <andreas.buhr@qt.io> | 2020-11-19 13:17:31 +0100 |
---|---|---|
committer | Andreas Buhr <andreas.buhr@qt.io> | 2020-11-19 23:56:15 +0100 |
commit | 06f58a909bcdcd08d125f5decd1fba894c285765 (patch) | |
tree | 0d7c31dd1b9ac291eac69c7dbec831d4413d1530 /tests/auto/corelib/text/qstring | |
parent | ebaae45ea17efc230209ed90d94596647cf6cb48 (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>
Diffstat (limited to 'tests/auto/corelib/text/qstring')
-rw-r--r-- | tests/auto/corelib/text/qstring/tst_qstring.cpp | 10 |
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() |