10 #define TEST_STRINGIFY(x) #x
14 inline void test_failed(
char const* expr,
char const* file,
int line)
16 std::cerr << file <<
", line " << line <<
": test failed: " << expr <<
'\n';
21 inline void test_run(
bool condition,
char const* expr,
char const* file,
int line)
24 test_failed(expr, file, line);
29 inline void test_exception(std::exception
const& ex,
char const* expr,
char const* file,
int line)
31 std::string msg( expr );
32 msg +=
" threw an exception: ";
34 test_failed(msg.c_str(), file, line);
47 test_run(x, TEST_STRINGIFY(x), __FILE__, __LINE__);\
49 catch(std::exception const& ex)\
51 test_exception(ex, TEST_STRINGIFY(x), __FILE__, __LINE__);\