tst_QRegularExpression: port to QTEST_THROW_ON_FAIL

Dogfooding the new QtTest 6.8 feature.

Change-Id: I530814c0858565b46f462d5c66038a37140c0617
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 7885d5cb220cee04f892ecdba46a1fc3dc65eeae)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-06-17 09:26:48 +02:00 committed by Qt Cherry-pick Bot
parent 7e021ab891
commit 9a86dba130
3 changed files with 10 additions and 12 deletions

View File

@ -15,7 +15,9 @@ add_subdirectory(qchar)
add_subdirectory(qcollator)
add_subdirectory(qlatin1stringmatcher)
add_subdirectory(qlatin1stringview)
if (NOT WASM) # QTBUG-121822
add_subdirectory(qregularexpression)
endif()
add_subdirectory(qstring)
add_subdirectory(qstring_no_cast_from_bytearray)
add_subdirectory(qstringapisymmetry)

View File

@ -14,6 +14,10 @@ endif()
qt_internal_add_test(tst_qregularexpression
SOURCES
tst_qregularexpression.cpp
NO_BATCH # QTBUG-121815
DEFINES
QTEST_THROW_ON_FAIL
QTEST_THROW_ON_SKIP
LIBRARIES
Qt::TestPrivate
)

View File

@ -16,6 +16,10 @@
#include <iostream>
#include <optional>
#ifndef QTEST_THROW_ON_FAIL
# error This test requires QTEST_THROW_ON_FAIL being active.
#endif
Q_DECLARE_METATYPE(QRegularExpression::PatternOptions)
Q_DECLARE_METATYPE(QRegularExpression::MatchType)
Q_DECLARE_METATYPE(QRegularExpression::MatchOptions)
@ -292,11 +296,7 @@ void consistencyCheck(const QRegularExpressionMatchIterator &iterator)
QRegularExpressionMatch peeked = i.peekNext();
QRegularExpressionMatch match = i.next();
consistencyCheck(peeked);
if (QTest::currentTestFailed())
return;
consistencyCheck(match);
if (QTest::currentTestFailed())
return;
QVERIFY(match.isValid());
QVERIFY(match.hasMatch() || match.hasPartialMatch());
QCOMPARE(i.regularExpression(), match.regularExpression());
@ -544,8 +544,6 @@ void tst_QRegularExpression::moveSemanticsMatch()
QCOMPARE(match2.capturedStart(), 3);
QCOMPARE(match2.capturedEnd(), 7);
consistencyCheck(match2);
if (QTest::currentTestFailed())
return;
QRegularExpressionMatch match3 = re.match("test1");
QCOMPARE(match3.hasMatch(), true);
@ -558,8 +556,6 @@ void tst_QRegularExpression::moveSemanticsMatch()
QCOMPARE(match1.capturedStart(), 0);
QCOMPARE(match1.capturedEnd(), 4);
consistencyCheck(match1);
if (QTest::currentTestFailed())
return;
// here match3 is in the moved-from state, so destructor call for moved-from
// object is also checked
@ -578,8 +574,6 @@ void tst_QRegularExpression::moveSemanticsMatchIterator()
QVERIFY(it2.hasNext());
QT_TEST_EQUALITY_OPS(it2.regularExpression(), re, true);
consistencyCheck(it2);
if (QTest::currentTestFailed())
return;
QRegularExpression re2("test");
QRegularExpressionMatchIterator it3 = re2.globalMatch("123test456");
@ -593,8 +587,6 @@ void tst_QRegularExpression::moveSemanticsMatchIterator()
QVERIFY(it1.hasNext());
QT_TEST_EQUALITY_OPS(it1.regularExpression(), re2, true);
consistencyCheck(it1);
if (QTest::currentTestFailed())
return;
// here it3 is in the moved-from state, so destructor call for moved-from
// object is also checked