put each test in separate scope to avoid redefinition

This commit is contained in:
jacekpoz 2024-04-30 12:18:43 +02:00
parent 5443eeb7b9
commit 39e3b16568
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -32,17 +32,19 @@
} }
#define TEST(name, ...) \ #define TEST(name, ...) \
uint asserts_failed = 0;\ {\
uint asserts_total = 0;\ uint asserts_failed = 0;\
tests_total += 1;\ uint asserts_total = 0;\
std::cout << " RUNNING TEST `" << name << "`\n";\ tests_total += 1;\
__VA_ARGS__\ std::cout << " RUNNING TEST `" << name << "`\n";\
std::cout << " PASSED ASSERTS: "\ __VA_ARGS__\
<< (asserts_failed != 0 ? BG(255, 0, 0) : BG(0, 255, 0))\ std::cout << " PASSED ASSERTS: "\
<< FG(0, 0, 0)\ << (asserts_failed != 0 ? BG(255, 0, 0) : BG(0, 255, 0))\
<< (asserts_total - asserts_failed) << "/" << asserts_total\ << FG(0, 0, 0)\
<< RESET\ << (asserts_total - asserts_failed) << "/" << asserts_total\
<< "\n";\ << RESET\
if (asserts_failed > 0) {\ << "\n";\
tests_failed += 1;\ if (asserts_failed > 0) {\
tests_failed += 1;\
}\
} }