Skip to content

Commit

Permalink
test.h: silence unused result 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 1bfab6a
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions subprojects/test.h/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,39 @@ static inline void __attribute__((constructor(102))) run_tests(void) {
#include <stdbool.h>

#define TEST_CASE(name) static void __attribute__((unused)) __test_h_##name(void)

#define TEST__IGNORE_UNUSED_RESULT() \
_Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Wunused-result\"")
#define TEST__POP_DIAGNOSTIC() _Pragma("GCC diagnostic pop")
#define TEST_EQUAL(a, b) \
TEST__IGNORE_UNUSED_RESULT(); \
(void)(a); \
(void)(b)
(void)(b); \
TEST__POP_DIAGNOSTIC()
#define TEST_NOTEQUAL(a, b) \
TEST__IGNORE_UNUSED_RESULT(); \
(void)(a); \
(void)(b); \
TEST__POP_DIAGNOSTIC()
#define TEST_TRUE(a) \
TEST__IGNORE_UNUSED_RESULT(); \
(void)(a); \
(void)(b)
#define TEST_TRUE(a) (void)(a)
TEST__POP_DIAGNOSTIC()
#define TEST_STREQUAL(a, b) \
TEST__IGNORE_UNUSED_RESULT(); \
(void)(a); \
(void)(b)
(void)(b); \
TEST__POP_DIAGNOSTIC()
#define TEST_STRNEQUAL(a, b, len) \
TEST__IGNORE_UNUSED_RESULT(); \
(void)(a); \
(void)(b); \
(void)(len)
(void)(len); \
TEST__POP_DIAGNOSTIC()
#define TEST_STREQUAL3(str, expected, len) \
TEST__IGNORE_UNUSED_RESULT(); \
(void)(str); \
(void)(expected); \
(void)(len)
(void)(len); \
TEST__POP_DIAGNOSTIC()
#endif

0 comments on commit 1bfab6a

Please sign in to comment.