Skip to content

Commit

Permalink
test.h: silence must_use warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Yuxuan Shui <[email protected]>
  • Loading branch information
yshui committed Jun 30, 2024
1 parent 3a49a16 commit ac4a806
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions subprojects/test.h/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ac4a806

Please sign in to comment.