#ifndef SPONGE_TESTS_TEST_SHOULD_BE_HH #define SPONGE_TESTS_TEST_SHOULD_BE_HH #include "string_conversions.hh" #include #include #include #include #define test_should_be(act, exp) _test_should_be(act, exp, #act, #exp, __LINE__) template static void _test_should_be(const T &actual, const T &expected, const char *actual_s, const char *expected_s, const int lineno) { if (actual != expected) { std::ostringstream ss; ss << "`" << actual_s << "` should have been `" << expected_s << "`, but the former is\n\t" << to_string(actual) << "\nand the latter is\n\t" << to_string(expected) << " (difference of " << expected - actual << ")\n" << " (at line " << lineno << ")\n"; throw std::runtime_error(ss.str()); } } #endif // SPONGE_TESTS_TEST_SHOULD_BE_HH