Some better assertion macros

This commit is contained in:
Imbus 2025-01-11 17:33:06 +01:00
parent 1a0b3697f2
commit 91bf5ecec0

View file

@ -8,3 +8,24 @@
assert(cond); \ assert(cond); \
} \ } \
} while (0) } while (0)
#define ASSERT_EQ(expected, actual) \
do { \
if ((expected) != (actual)) { \
std::cerr << "Assertion failed: (" #expected " == " #actual ") " \
<< "Expected: " << (expected) \
<< ", Actual: " << (actual) << "\n"; \
assert((expected) == (actual)); \
} \
} while (0)
#define ASSERT_EQMSG(expected, actual, msg) \
do { \
if ((expected) != (actual)) { \
std::cerr << "Assertion failed: " << msg << "\n" \
<< "(" #expected " == " #actual ") " \
<< "Expected: " << (expected) \
<< ", Actual: " << (actual) << "\n"; \
assert((expected) == (actual)); \
} \
} while (0)