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:
parent
7e021ab891
commit
9a86dba130
@ -15,7 +15,9 @@ add_subdirectory(qchar)
|
|||||||
add_subdirectory(qcollator)
|
add_subdirectory(qcollator)
|
||||||
add_subdirectory(qlatin1stringmatcher)
|
add_subdirectory(qlatin1stringmatcher)
|
||||||
add_subdirectory(qlatin1stringview)
|
add_subdirectory(qlatin1stringview)
|
||||||
|
if (NOT WASM) # QTBUG-121822
|
||||||
add_subdirectory(qregularexpression)
|
add_subdirectory(qregularexpression)
|
||||||
|
endif()
|
||||||
add_subdirectory(qstring)
|
add_subdirectory(qstring)
|
||||||
add_subdirectory(qstring_no_cast_from_bytearray)
|
add_subdirectory(qstring_no_cast_from_bytearray)
|
||||||
add_subdirectory(qstringapisymmetry)
|
add_subdirectory(qstringapisymmetry)
|
||||||
|
@ -14,6 +14,10 @@ endif()
|
|||||||
qt_internal_add_test(tst_qregularexpression
|
qt_internal_add_test(tst_qregularexpression
|
||||||
SOURCES
|
SOURCES
|
||||||
tst_qregularexpression.cpp
|
tst_qregularexpression.cpp
|
||||||
|
NO_BATCH # QTBUG-121815
|
||||||
|
DEFINES
|
||||||
|
QTEST_THROW_ON_FAIL
|
||||||
|
QTEST_THROW_ON_SKIP
|
||||||
LIBRARIES
|
LIBRARIES
|
||||||
Qt::TestPrivate
|
Qt::TestPrivate
|
||||||
)
|
)
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <optional>
|
#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::PatternOptions)
|
||||||
Q_DECLARE_METATYPE(QRegularExpression::MatchType)
|
Q_DECLARE_METATYPE(QRegularExpression::MatchType)
|
||||||
Q_DECLARE_METATYPE(QRegularExpression::MatchOptions)
|
Q_DECLARE_METATYPE(QRegularExpression::MatchOptions)
|
||||||
@ -292,11 +296,7 @@ void consistencyCheck(const QRegularExpressionMatchIterator &iterator)
|
|||||||
QRegularExpressionMatch peeked = i.peekNext();
|
QRegularExpressionMatch peeked = i.peekNext();
|
||||||
QRegularExpressionMatch match = i.next();
|
QRegularExpressionMatch match = i.next();
|
||||||
consistencyCheck(peeked);
|
consistencyCheck(peeked);
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
consistencyCheck(match);
|
consistencyCheck(match);
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
QVERIFY(match.isValid());
|
QVERIFY(match.isValid());
|
||||||
QVERIFY(match.hasMatch() || match.hasPartialMatch());
|
QVERIFY(match.hasMatch() || match.hasPartialMatch());
|
||||||
QCOMPARE(i.regularExpression(), match.regularExpression());
|
QCOMPARE(i.regularExpression(), match.regularExpression());
|
||||||
@ -544,8 +544,6 @@ void tst_QRegularExpression::moveSemanticsMatch()
|
|||||||
QCOMPARE(match2.capturedStart(), 3);
|
QCOMPARE(match2.capturedStart(), 3);
|
||||||
QCOMPARE(match2.capturedEnd(), 7);
|
QCOMPARE(match2.capturedEnd(), 7);
|
||||||
consistencyCheck(match2);
|
consistencyCheck(match2);
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QRegularExpressionMatch match3 = re.match("test1");
|
QRegularExpressionMatch match3 = re.match("test1");
|
||||||
QCOMPARE(match3.hasMatch(), true);
|
QCOMPARE(match3.hasMatch(), true);
|
||||||
@ -558,8 +556,6 @@ void tst_QRegularExpression::moveSemanticsMatch()
|
|||||||
QCOMPARE(match1.capturedStart(), 0);
|
QCOMPARE(match1.capturedStart(), 0);
|
||||||
QCOMPARE(match1.capturedEnd(), 4);
|
QCOMPARE(match1.capturedEnd(), 4);
|
||||||
consistencyCheck(match1);
|
consistencyCheck(match1);
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// here match3 is in the moved-from state, so destructor call for moved-from
|
// here match3 is in the moved-from state, so destructor call for moved-from
|
||||||
// object is also checked
|
// object is also checked
|
||||||
@ -578,8 +574,6 @@ void tst_QRegularExpression::moveSemanticsMatchIterator()
|
|||||||
QVERIFY(it2.hasNext());
|
QVERIFY(it2.hasNext());
|
||||||
QT_TEST_EQUALITY_OPS(it2.regularExpression(), re, true);
|
QT_TEST_EQUALITY_OPS(it2.regularExpression(), re, true);
|
||||||
consistencyCheck(it2);
|
consistencyCheck(it2);
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QRegularExpression re2("test");
|
QRegularExpression re2("test");
|
||||||
QRegularExpressionMatchIterator it3 = re2.globalMatch("123test456");
|
QRegularExpressionMatchIterator it3 = re2.globalMatch("123test456");
|
||||||
@ -593,8 +587,6 @@ void tst_QRegularExpression::moveSemanticsMatchIterator()
|
|||||||
QVERIFY(it1.hasNext());
|
QVERIFY(it1.hasNext());
|
||||||
QT_TEST_EQUALITY_OPS(it1.regularExpression(), re2, true);
|
QT_TEST_EQUALITY_OPS(it1.regularExpression(), re2, true);
|
||||||
consistencyCheck(it1);
|
consistencyCheck(it1);
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// here it3 is in the moved-from state, so destructor call for moved-from
|
// here it3 is in the moved-from state, so destructor call for moved-from
|
||||||
// object is also checked
|
// object is also checked
|
||||||
|
Loading…
x
Reference in New Issue
Block a user