summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-11-23 20:43:08 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-12-01 06:59:16 +0000
commit2fa63f352ae9094e6fd12537bffb9ff0b9b2b64a (patch)
tree54bec41346b30441ec3af4c37d8fdf4b8b983f22
parente5f94b3b1ff01e44b9d53bdd0822b37b9778aa2d (diff)
downloadqtbase-2fa63f352ae9094e6fd12537bffb9ff0b9b2b64a.tar.gz
tst_QString: check empty regex can replace in empty/null string
It's not intuitive, so check lest people break it. Change-Id: I2435cd69be7b77a6ae59cdc7b5fb99658cfc42fd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit d1a37ab0997fbe393fb9cca7158dfa59041f165d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-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 e15682e81e..676ff7c29c 100644
--- a/tests/auto/corelib/text/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp
@@ -856,6 +856,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");