diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-06-08 17:48:16 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-08-19 08:49:07 +0200 |
commit | 11d1dcc6e263c5059f34b44d531c9ccdf7c0b1d6 (patch) | |
tree | cd32196502def427e8ddfdef417574d17b10490e /tests/auto/corelib | |
parent | f0d1f50e0294e5a55a0e450993e0810bd4dbf63d (diff) |
QString: use the QRegularExpression operations on QStringView
There's no need of duplicating code all over the place; QString can
reuse the implementation of the indexOf/contains/count/lastIndexOf
family of functions already existing for QStringView.
For simplicity, the warning messages (that our autotests actually check)
have been made more generic, rather than introducing some other
parameter (as in, "which class is using this functionality so to emit
a more precise warning"), which would have just complicated things as
the implementation of these functions is exported and used by inline
QStringView member functions.
Change-Id: I85cd94a31c82b00d61341b3058b954749a2d6c6b
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 | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 813e247013..7ad218be96 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -1687,14 +1687,14 @@ void tst_QString::indexOf2() #if QT_CONFIG(regularexpression) void tst_QString::indexOfInvalidRegex() { - QTest::ignoreMessage(QtWarningMsg, "QString::indexOf: invalid QRegularExpression object"); + QTest::ignoreMessage(QtWarningMsg, "QString(View)::indexOf: invalid QRegularExpression object"); QCOMPARE(QString("invalid regex\\").indexOf(QRegularExpression("invalid regex\\")), -1); - QTest::ignoreMessage(QtWarningMsg, "QString::indexOf: invalid QRegularExpression object"); + QTest::ignoreMessage(QtWarningMsg, "QString(View)::indexOf: invalid QRegularExpression object"); QCOMPARE(QString("invalid regex\\").indexOf(QRegularExpression("invalid regex\\"), -1, nullptr), -1); QRegularExpressionMatch match; QVERIFY(!match.hasMatch()); - QTest::ignoreMessage(QtWarningMsg, "QString::indexOf: invalid QRegularExpression object"); + QTest::ignoreMessage(QtWarningMsg, "QString(View)::indexOf: invalid QRegularExpression object"); QCOMPARE(QString("invalid regex\\").indexOf(QRegularExpression("invalid regex\\"), -1, &match), -1); QVERIFY(!match.hasMatch()); } @@ -1813,14 +1813,14 @@ void tst_QString::lastIndexOf() #if QT_CONFIG(regularexpression) void tst_QString::lastIndexOfInvalidRegex() { - QTest::ignoreMessage(QtWarningMsg, "QString::lastIndexOf: invalid QRegularExpression object"); + QTest::ignoreMessage(QtWarningMsg, "QString(View)::lastIndexOf: invalid QRegularExpression object"); QCOMPARE(QString("invalid regex\\").lastIndexOf(QRegularExpression("invalid regex\\"), 0), -1); - QTest::ignoreMessage(QtWarningMsg, "QString::lastIndexOf: invalid QRegularExpression object"); + QTest::ignoreMessage(QtWarningMsg, "QString(View)::lastIndexOf: invalid QRegularExpression object"); QCOMPARE(QString("invalid regex\\").lastIndexOf(QRegularExpression("invalid regex\\"), -1, nullptr), -1); QRegularExpressionMatch match; QVERIFY(!match.hasMatch()); - QTest::ignoreMessage(QtWarningMsg, "QString::lastIndexOf: invalid QRegularExpression object"); + QTest::ignoreMessage(QtWarningMsg, "QString(View)::lastIndexOf: invalid QRegularExpression object"); QCOMPARE(QString("invalid regex\\").lastIndexOf(QRegularExpression("invalid regex\\"), -1, &match), -1); QVERIFY(!match.hasMatch()); } @@ -1843,7 +1843,7 @@ void tst_QString::count() QCOMPARE(a.count(QRegularExpression("")), 16); QCOMPARE(a.count(QRegularExpression("[FG][HI]")), 1); QCOMPARE(a.count(QRegularExpression("[G][HE]")), 2); - QTest::ignoreMessage(QtWarningMsg, "QString::count: invalid QRegularExpression object"); + QTest::ignoreMessage(QtWarningMsg, "QString(View)::count: invalid QRegularExpression object"); QCOMPARE(a.count(QRegularExpression("invalid regex\\")), 0); #endif @@ -1862,7 +1862,7 @@ void tst_QString::count() #if QT_CONFIG(regularexpression) QCOMPARE(nullStr.count(QRegularExpression("")), 1); QCOMPARE(nullStr.count(QRegularExpression("[FG][HI]")), 0); - QTest::ignoreMessage(QtWarningMsg, "QString::count: invalid QRegularExpression object"); + QTest::ignoreMessage(QtWarningMsg, "QString(View)::count: invalid QRegularExpression object"); QCOMPARE(nullStr.count(QRegularExpression("invalid regex\\")), 0); #endif @@ -1876,7 +1876,7 @@ void tst_QString::count() #if QT_CONFIG(regularexpression) QCOMPARE(emptyStr.count(QRegularExpression("")), 1); QCOMPARE(emptyStr.count(QRegularExpression("[FG][HI]")), 0); - QTest::ignoreMessage(QtWarningMsg, "QString::count: invalid QRegularExpression object"); + QTest::ignoreMessage(QtWarningMsg, "QString(View)::count: invalid QRegularExpression object"); QCOMPARE(emptyStr.count(QRegularExpression("invalid regex\\")), 0); #endif } @@ -1949,7 +1949,7 @@ void tst_QString::contains() QVERIFY(!a.contains(QRegularExpression("ZZZ"), 0)); } - QTest::ignoreMessage(QtWarningMsg, "QString::contains: invalid QRegularExpression object"); + QTest::ignoreMessage(QtWarningMsg, "QString(View)::contains: invalid QRegularExpression object"); QVERIFY(!a.contains(QRegularExpression("invalid regex\\"))); #endif |