From f42eb2aabc1700542fe7dd33a3361295ee56275b Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 11 Jul 2022 16:46:40 +0200 Subject: Skip some spurious parentheses on macro argument uses When an argument to one macro appears as a single argument to another macro, the usual "put it in parentheses" rule doesn't apply since it's necessarily something the right shape to be a macro parameter. In some cases, furthermore, the added parentheses could show up in the output produced by a test when reporting an expression that was compared or verified. Also removed the parentheses around one comparison. Change-Id: I226f4356fb057351187dac2134cc12c06026c40c Reviewed-by: Ivan Solovev Reviewed-by: Mitch Curtis (cherry picked from commit 2648b4ad2c5e90fc7a074b6e469d4b54fb0bf724) Reviewed-by: Qt Cherry-pick Bot --- src/testlib/qtestcase.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index ad941d2ba3..a0df8dd305 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -167,7 +167,7 @@ inline void useVerifyThrowsException() {} #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))); \ @@ -177,36 +177,36 @@ 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_TIMEOUT_DEBUG_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) -#define QTRY_VERIFY(expr) QTRY_VERIFY_WITH_TIMEOUT((expr), 5000) +#define QTRY_VERIFY(expr) QTRY_VERIFY_WITH_TIMEOUT(expr, 5000) // 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) -#define QTRY_VERIFY2(expr, messageExpression) QTRY_VERIFY2_WITH_TIMEOUT((expr), (messageExpression), 5000) +#define QTRY_VERIFY2(expr, messageExpression) QTRY_VERIFY2_WITH_TIMEOUT(expr, messageExpression, 5000) // 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) \ - QCOMPARE((expr), expected); \ + QTRY_IMPL((expr) == (expected), timeout) \ + QCOMPARE(expr, expected); \ } while (false) -#define QTRY_COMPARE(expr, expected) QTRY_COMPARE_WITH_TIMEOUT((expr), expected, 5000) +#define QTRY_COMPARE(expr, expected) QTRY_COMPARE_WITH_TIMEOUT(expr, expected, 5000) #define QTRY_COMPARE_OP_WITH_TIMEOUT_IMPL(left, right, op, opId, timeout) \ do { \ -- cgit v1.2.1