31 lines
1.9 KiB
C++
31 lines
1.9 KiB
C++
#include <cassert>
|
|
#include <iostream>
|
|
|
|
#define ASSERT_MSG(cond, msg) \
|
|
do { \
|
|
if (!(cond)) { \
|
|
std::cerr << "Assertion failed: " << msg << "\n"; \
|
|
assert(cond); \
|
|
} \
|
|
} 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)
|