diff options
author | Andreas Buhr <andreas.buhr@qt.io> | 2020-11-19 14:26:18 +0100 |
---|---|---|
committer | Andreas Buhr <andreas.buhr@qt.io> | 2020-11-19 20:28:27 +0100 |
commit | ebaae45ea17efc230209ed90d94596647cf6cb48 (patch) | |
tree | 649ef0a6282b274ff8776d091106829bebb6b1ce /tests/auto/corelib | |
parent | d3ba1b321b23eb807e3af9bfaa3a0db6d7a153c7 (diff) |
Fix logic error in QString::replace(ch, after, cs)
Coverage analysis showed that an if-branch marked "Q_LIKELY" was never
taken. It turns out the code was incorrect, but behaved correctly.
This patch fixes the logic and adds a unit test.
Pick-to: 5.15
Change-Id: I9b4ba76392b52f07b8e21188496e23f98dba95a9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/text/qstring/tst_qstring.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 47470abd6f..e6d73c6ef1 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -2876,6 +2876,17 @@ void tst_QString::replace_string_extra() s.replace( QString("BBB"), smallReplacement ); QCOMPARE( s, smallReplacement ); } + + { + QString s(QLatin1String("BBB")); + QString expected(QLatin1String("BBB")); + for (int i = 0; i < 1028; ++i) { + s.append("X"); + expected.append("GXU"); + } + s.replace(QChar('X'), "GXU"); + QCOMPARE(s, expected); + } } void tst_QString::replace_regexp() |