diff --git a/subprojects/test.h/test.h b/subprojects/test.h/test.h index 3aa722022e..596026d7dc 100644 --- a/subprojects/test.h/test.h +++ b/subprojects/test.h/test.h @@ -222,22 +222,38 @@ static inline void __attribute__((constructor(102))) run_tests(void) { #define TEST_CASE(name) static void __attribute__((unused)) __test_h_##name(void) +#define TEST__DISCARD(v) \ + __auto_type test_h_unused_##__COUNTER__ __attribute__((unused)) = (v) + #define TEST_EQUAL(a, b) \ - (void)(a); \ - (void)(b) + do { \ + TEST__DISCARD(a); \ + TEST__DISCARD(b); \ + } while (0) #define TEST_NOTEQUAL(a, b) \ - (void)(a); \ - (void)(b) -#define TEST_TRUE(a) (void)(a) + do { \ + TEST__DISCARD(a); \ + TEST__DISCARD(b); \ + } while (0) +#define TEST_TRUE(a) \ + do { \ + TEST__DISCARD(a); \ + } while (0) #define TEST_STREQUAL(a, b) \ - (void)(a); \ - (void)(b) + do { \ + TEST__DISCARD(a); \ + TEST__DISCARD(b); \ + } while (0) #define TEST_STRNEQUAL(a, b, len) \ - (void)(a); \ - (void)(b); \ - (void)(len) + do { \ + TEST__DISCARD(a); \ + TEST__DISCARD(b); \ + TEST__DISCARD(len); \ + } while (0) #define TEST_STREQUAL3(str, expected, len) \ - (void)(str); \ - (void)(expected); \ - (void)(len) + do { \ + TEST__DISCARD(str); \ + TEST__DISCARD(expected); \ + TEST__DISCARD(len); \ + } while (0) #endif