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, ...) \
uint asserts_failed = 0;\
uint asserts_total = 0;\
tests_total += 1;\
std::cout << " RUNNING TEST `" << name << "`\n";\
__VA_ARGS__\
std::cout << " PASSED ASSERTS: "\
<< (asserts_failed != 0 ? BG(255, 0, 0) : BG(0, 255, 0))\
<< FG(0, 0, 0)\
<< (asserts_total - asserts_failed) << "/" << asserts_total\
<< RESET\
<< "\n";\
if (asserts_failed > 0) {\
tests_failed += 1;\
{\
uint asserts_failed = 0;\
uint asserts_total = 0;\
tests_total += 1;\
std::cout << " RUNNING TEST `" << name << "`\n";\
__VA_ARGS__\
std::cout << " PASSED ASSERTS: "\
<< (asserts_failed != 0 ? BG(255, 0, 0) : BG(0, 255, 0))\
<< FG(0, 0, 0)\
<< (asserts_total - asserts_failed) << "/" << asserts_total\
<< RESET\
<< "\n";\
if (asserts_failed > 0) {\
tests_failed += 1;\
}\
}