summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-11-23 20:43:08 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-11-27 17:14:28 +0100
commitd1a37ab0997fbe393fb9cca7158dfa59041f165d (patch)
tree118783d4103d367208643604b5a5efec311220ea /tests
parentc72bf262ea1f8eb80b7b4c9a56f6bd9e6f77cee4 (diff)
tst_QString: check empty regex can replace in empty/null string
It's not intuitive, so check lest people break it. Pick-to: 6.4 6.2 Change-Id: I2435cd69be7b77a6ae59cdc7b5fb99658cfc42fd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/text/qstring/tst_qstring.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp
index 600b97f1bf..42a4b99d0b 100644
--- a/tests/auto/corelib/text/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp
@@ -861,6 +861,9 @@ void tst_QString::replace_regexp_data()
// Columns (all QString): string, regexp, after, result; string.replace(regexp, after) == result
// Test-cases with empty after (replacement text, third column) go in remove_regexp_data()
+ QTest::newRow("empty-in-null") << QString() << "" << "after" << "after";
+ QTest::newRow("empty-in-empty") << "" << "" << "after" << "after";
+
QTest::newRow( "rep00" ) << QString("A <i>bon mot</i>.") << QString("<i>([^<]*)</i>") << QString("\\emph{\\1}") << QString("A \\emph{bon mot}.");
QTest::newRow( "rep01" ) << QString("banana") << QString("^.a()") << QString("\\1") << QString("nana");
QTest::newRow( "rep02" ) << QString("banana") << QString("(ba)") << QString("\\1X\\1") << QString("baXbanana");