Some better assertion macros
This commit is contained in:
parent
1a0b3697f2
commit
91bf5ecec0
1 changed files with 21 additions and 0 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue