diff options
author | Mitch Curtis <mitch.curtis@digia.com> | 2013-03-11 13:58:35 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-12 11:43:01 +0100 |
commit | c1771a78ed0ceab26891b3fdf801dc5557173fac (patch) | |
tree | 9d3020aa62787f67863b6ab80b92def8702afc5f /tests | |
parent | 6bc691dde53a3056d708d94d8bb1317d622835b0 (diff) |
Correct QString's warnings involving QRegularExpression.
Replaces "QRegularExpresssion" with "QRegularExpression" and adds some
auto tests for the warning itself.
Task-number: QTBUG-30054
Change-Id: Iba333a4388795eccca809fb430c295f503794263
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/tools/qstring/tst_qstring.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 8e30a66d6f..7b7869d033 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -156,6 +156,7 @@ private slots: void count(); void lastIndexOf_data(); void lastIndexOf(); + void lastIndexOfInvalidRegex(); void indexOf_data(); void indexOf(); void indexOf2_data(); @@ -633,6 +634,7 @@ void tst_QString::replace_regexp_data() << QString("a9a8a7a6a5nmlkjii0hh0gg0ff0ee0dd0cc0bb0a"); QTest::newRow("backref10") << QString("abc") << QString("((((((((((((((abc))))))))))))))") << QString("\\0\\01\\011") << QString("\\0\\01\\011"); + QTest::newRow("invalid") << QString("") << QString("invalid regex\\") << QString("") << QString(""); } void tst_QString::utf8_data() @@ -1379,6 +1381,12 @@ void tst_QString::lastIndexOf() } } +void tst_QString::lastIndexOfInvalidRegex() +{ + QTest::ignoreMessage(QtWarningMsg, "QString::lastIndexOf: invalid QRegularExpression object"); + QCOMPARE(QString("").lastIndexOf(QRegularExpression("invalid regex\\"), 0), -1); +} + void tst_QString::count() { QString a; @@ -1396,7 +1404,8 @@ void tst_QString::count() QCOMPARE(a.count(QRegExp("[G][HE]")),2); QCOMPARE(a.count(QRegularExpression("[FG][HI]")), 1); QCOMPARE(a.count(QRegularExpression("[G][HE]")), 2); - + QTest::ignoreMessage(QtWarningMsg, "QString::count: invalid QRegularExpression object"); + QCOMPARE(a.count(QRegularExpression("invalid regex\\")), 0); CREATE_REF(QLatin1String("FG")); QCOMPARE(a.count(ref),2); @@ -1432,6 +1441,8 @@ void tst_QString::contains() QStringRef emptyRef(&a, 0, 0); QVERIFY(a.contains(emptyRef, Qt::CaseInsensitive)); + QTest::ignoreMessage(QtWarningMsg, "QString::contains: invalid QRegularExpression object"); + QVERIFY(!a.contains(QRegularExpression("invalid regex\\"))); } @@ -2342,7 +2353,10 @@ void tst_QString::replace_regexp() s2.replace( QRegExp(regexp), after ); QTEST( s2, "result" ); s2 = string; - s2.replace( QRegularExpression(regexp), after ); + QRegularExpression regularExpression(regexp); + if (!regularExpression.isValid()) + QTest::ignoreMessage(QtWarningMsg, "QString::replace: invalid QRegularExpression object"); + s2.replace( regularExpression, after ); QTEST( s2, "result" ); } |