summaryrefslogtreecommitdiff
path: root/src/testlib
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-07-11 16:46:40 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-07-25 17:29:39 +0000
commitf42eb2aabc1700542fe7dd33a3361295ee56275b (patch)
tree8ed430c51964524eee1694b18e2e9311fc224edc /src/testlib
parent812c10fcedbd79d9c2a4e651b393596d5292764c (diff)
downloadqtbase-f42eb2aabc1700542fe7dd33a3361295ee56275b.tar.gz
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 <ivan.solovev@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 2648b4ad2c5e90fc7a074b6e469d4b54fb0bf724) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtestcase.h20
1 files changed, 10 insertions, 10 deletions
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 { \