Add test macros: SG_CHECK_NE, SG_CHECK_LT, SG_CHECK_LE, SG_CHECK_GT, SG_CHECK_GE

This commit is contained in:
Florent Rougon 2016-12-04 17:07:36 +01:00
parent b4178ae888
commit 90479419cc

View File

@ -36,6 +36,46 @@
exit(1); \
}
#define SG_CHECK_NE(a, b) \
if ( !((a) != (b)) ) { \
std::cerr << "failed: " << #a << " != " << #b << std::endl; \
std::cerr << "\tgot '" << a << "' and '" << b << "'" << std::endl; \
std::cerr << "\tat " << __FILE__ << ":" << __LINE__ << std::endl; \
exit(1); \
}
#define SG_CHECK_LT(a, b) \
if ( !((a) < (b)) ) { \
std::cerr << "failed: " << #a << " < " << #b << std::endl; \
std::cerr << "\tgot '" << a << "' and '" << b << "'" << std::endl; \
std::cerr << "\tat " << __FILE__ << ":" << __LINE__ << std::endl; \
exit(1); \
}
#define SG_CHECK_LE(a, b) \
if ( !((a) <= (b)) ) { \
std::cerr << "failed: " << #a << " <= " << #b << std::endl; \
std::cerr << "\tgot '" << a << "' and '" << b << "'" << std::endl; \
std::cerr << "\tat " << __FILE__ << ":" << __LINE__ << std::endl; \
exit(1); \
}
#define SG_CHECK_GT(a, b) \
if ( !((a) > (b)) ) { \
std::cerr << "failed: " << #a << " > " << #b << std::endl; \
std::cerr << "\tgot '" << a << "' and '" << b << "'" << std::endl; \
std::cerr << "\tat " << __FILE__ << ":" << __LINE__ << std::endl; \
exit(1); \
}
#define SG_CHECK_GE(a, b) \
if ( !((a) >= (b)) ) { \
std::cerr << "failed: " << #a << " >= " << #b << std::endl; \
std::cerr << "\tgot '" << a << "' and '" << b << "'" << std::endl; \
std::cerr << "\tat " << __FILE__ << ":" << __LINE__ << std::endl; \
exit(1); \
}
#define SG_TEST_FAIL(msg) \
std::cerr << "failure: " << msg; \
exit(1);