From d1a37ab0997fbe393fb9cca7158dfa59041f165d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 23 Nov 2022 20:43:08 +0100 Subject: [PATCH] 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 Reviewed-by: Thiago Macieira --- tests/auto/corelib/text/qstring/tst_qstring.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 600b97f1bf7..42a4b99d0b5 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 bon mot.") << QString("([^<]*)") << 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");