diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2022-07-11 12:22:11 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2022-07-25 19:29:07 +0200 |
commit | a670a00aed4dbc9601df62c1ffd15352f6787bb6 (patch) | |
tree | 7d20dfa7dc60a48eabbe23d4cad91b390b950e08 /src/testlib/qtestcase.h | |
parent | 4048efc80c3085b7174b746bec1fa8406c56ed42 (diff) |
Skip semicolon after uses of QTRY_IMPL() and QTRY_LOOP_IMPL()
The macros' expansions end with an if-block and a for-block,
respectively, so the following semicolon is superfluous. Since we
control these macros' use (they're internals), just skip the
semicolons, rather than wrapping their bodies in do-while(0).
Pick-to: 6.4
Change-Id: I53f7786a66a0dc7709ac9f96d49985edafceec39
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/testlib/qtestcase.h')
-rw-r--r-- | src/testlib/qtestcase.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 3103cdc41c..ad941d2ba3 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -163,10 +163,11 @@ inline void useVerifyThrowsException() {} && !(expr); qt_test_i += step) { \ QTest::qWait(step); \ } +// Ends in a for-block, so doesn't want a following semicolon. #define QTRY_TIMEOUT_DEBUG_IMPL(expr, timeoutValue, step) \ if (!QTest::currentTestFailed() && !(expr)) { \ - QTRY_LOOP_IMPL((expr), 2 * (timeoutValue), step); \ + QTRY_LOOP_IMPL((expr), 2 * (timeoutValue), step) \ if (expr) { \ QFAIL(qPrintable(QTest::Internal::formatTryTimeoutDebugMessage(\ u8"" #expr, timeoutValue, timeoutValue + qt_test_i))); \ @@ -176,13 +177,14 @@ inline void useVerifyThrowsException() {} #define QTRY_IMPL(expr, timeout)\ const int qt_test_step = timeout < 350 ? timeout / 7 + 1 : 50; \ const int qt_test_timeoutValue = timeout; \ - { QTRY_LOOP_IMPL((expr), qt_test_timeoutValue, qt_test_step); } \ + { QTRY_LOOP_IMPL((expr), qt_test_timeoutValue, qt_test_step) } \ QTRY_TIMEOUT_DEBUG_IMPL((expr), qt_test_timeoutValue, qt_test_step) +// Ends with an if-block, so doesn't want a following semicolon. // Will try to wait for the expression to become true while allowing event processing #define QTRY_VERIFY_WITH_TIMEOUT(expr, timeout) \ do { \ - QTRY_IMPL((expr), timeout);\ + QTRY_IMPL((expr), timeout) \ QVERIFY(expr); \ } while (false) @@ -191,7 +193,7 @@ do { \ // Will try to wait for the expression to become true while allowing event processing #define QTRY_VERIFY2_WITH_TIMEOUT(expr, messageExpression, timeout) \ do { \ - QTRY_IMPL((expr), timeout);\ + QTRY_IMPL((expr), timeout) \ QVERIFY2(expr, messageExpression); \ } while (false) @@ -200,7 +202,7 @@ do { \ // Will try to wait for the comparison to become successful while allowing event processing #define QTRY_COMPARE_WITH_TIMEOUT(expr, expected, timeout) \ do { \ - QTRY_IMPL(((expr) == (expected)), timeout);\ + QTRY_IMPL(((expr) == (expected)), timeout) \ QCOMPARE((expr), expected); \ } while (false) @@ -208,7 +210,7 @@ do { \ #define QTRY_COMPARE_OP_WITH_TIMEOUT_IMPL(left, right, op, opId, timeout) \ do { \ - QTRY_IMPL(((left) op (right)), timeout); \ + QTRY_IMPL(((left) op (right)), timeout) \ QCOMPARE_OP_IMPL(left, right, op, opId); \ } while (false) |