summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib/selftests
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-12-10 17:14:35 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2022-01-21 16:17:48 +0100
commit5d80d24d3c1a58c7e617e7b671e3040039cde684 (patch)
tree8b7d111db261a9799e0f06d2783f529d874af924 /tests/auto/testlib/selftests
parent33af62db3747bb6fcb7490ef2d2abc5bb53925b6 (diff)
Tidy up tst_Warnings: comments and #if-ery
It was missing #if-ery on feature regularexpression for one test that depends on it. One of its comments had a long line. Added some annotations to make clear what's going on in messier tests. Change-Id: I06d8748a134591f93b36029713e52ffd826a24dc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/testlib/selftests')
-rw-r--r--tests/auto/testlib/selftests/warnings/tst_warnings.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
index ee73bd4fe4..40ebb17561 100644
--- a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
+++ b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
@@ -37,7 +37,9 @@ class tst_Warnings: public QObject
private slots:
void testWarnings();
void testMissingWarnings();
+#if QT_CONFIG(regularexpression)
void testMissingWarningsRegularExpression();
+#endif
void testMissingWarningsWithData_data();
void testMissingWarningsWithData();
@@ -109,6 +111,7 @@ void tst_Warnings::testMissingWarnings()
qWarning("Warning2");
}
+#if QT_CONFIG(regularexpression)
void tst_Warnings::testMissingWarningsRegularExpression()
{
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("Warning\\d\\d"));
@@ -116,6 +119,7 @@ void tst_Warnings::testMissingWarningsRegularExpression()
qWarning("Warning11");
}
+#endif
void tst_Warnings::testMissingWarningsWithData_data()
{
@@ -172,8 +176,9 @@ void tst_Warnings::testFailOnWarnings()
void tst_Warnings::testFailOnWarningsCleared()
{
// The patterns passed to failOnWarnings() should be cleared at the end of
- // each test function, so this shouldn't fail because of the failOnWarning() call in the previous function.
- // Note that this test always needs to come after testFailOnWarnings for it to work.
+ // each test function, so this shouldn't fail because of the failOnWarning()
+ // call in the previous function. Note that this test always needs to come
+ // after testFailOnWarnings for it to test anything meaningfully.
qWarning("Ran out of muffins!");
}
@@ -203,6 +208,7 @@ void tst_Warnings::testFailOnWarningsWithData()
void tst_Warnings::testFailOnWarningsFailInHelper()
{
[](){ QFAIL("This failure message should be printed but not cause the test to abort"); }();
+ // So we've already failed, but we get more messages - that don't increment counters.
const auto warnRegex = QRegularExpression("Ran out of .*!");
QTest::failOnWarning(warnRegex);
qWarning("Ran out of cabbage!");
@@ -214,7 +220,7 @@ void tst_Warnings::testFailOnWarningsThenSkip()
const auto warnRegex = QRegularExpression("Ran out of .*!");
QTest::failOnWarning(warnRegex);
qWarning("Ran out of cabbage!");
- QSKIP("My cabbage! :(");
+ QSKIP("My cabbage! :("); // Reports, but doesn't count.
}
#endif // QT_CONFIG(regularexpression)