Go to the documentation of this file.
25 #ifndef H_54E531F7_9154_454B_BEB9_257408429470
26 #define H_54E531F7_9154_454B_BEB9_257408429470
43 const char*
what()
const throw() {
44 if (not
_what.size()) {
45 std::ostringstream ss;
59 static const char*
_basename(
const char* filename) {
60 const char*
basename = filename + strlen(filename);
95 printf(
"!! %s\n", e.
what());
97 }
catch(
const std::exception& e) {
98 printf(
"!! exception: %s\n", e.what());
101 printf(
"!! unknown exception\n");
116 #define _TEST_STATUS(name, status) \
117 struct TEST_##name: ::test::TestBase { \
118 TEST_##name(): TestBase(#name, status) {} \
121 void TEST_##name::do_test()
123 #define TEST(name) _TEST_STATUS(name, ::test::SUCCESS)
124 #define TEST_FAIL(name) _TEST_STATUS(name, ::test::FAILED)
125 #define TEST_FAIL_ASSERT(name) _TEST_STATUS(name, ::test::ASSERT_FAIL)
126 #define TEST_UNCAUGHT_EXCEPTION(name) _TEST_STATUS(name, ::test::EXCEPTION_UNCAUGHT)
127 #define TEST_UNCAUGHT_SIGNAL(name) _TEST_STATUS(name, ::test::SIGNAL_UNCAUGHT)
128 #define TEST_SEGFAULT(name) _TEST_STATUS(name, ::test::SIGNAL_SEGFAULT)
129 #define TEST_ABORT(name) _TEST_STATUS(name, ::test::SIGNAL_ABORT)
130 #define TEST_DIVZERO(name) _TEST_STATUS(name, ::test::SIGNAL_DIVZERO)
132 #define ASSERT(expr) \
133 (expr) ? static_cast<void>(0) \
134 : throw ::test::AssertFailedError( \
135 __FILE__, __LINE__, #expr)
137 #define _ASSERT_BINOP(a, b, cmp) \
138 (not (a cmp b)) ? static_cast<void>(0) \
139 : throw ::test::AssertFailedError( \
140 __FILE__, __LINE__, "because " #a " " #cmp " " #b)
142 #define ASSERT_EQ(a, b) _ASSERT_BINOP(a, b, !=)
143 #define ASSERT_NE(a, b) _ASSERT_BINOP(a, b, ==)
144 #define ASSERT_LT(a, b) _ASSERT_BINOP(a, b, >=)
145 #define ASSERT_LE(a, b) _ASSERT_BINOP(a, b, >)
146 #define ASSERT_GT(a, b) _ASSERT_BINOP(a, b, <=)
147 #define ASSERT_GE(a, b) _ASSERT_BINOP(a, b, <)
149 #define ASSERT_THROW(expr, e_type) \
151 catch (const e_type&) { break; } \
152 throw ::test::AssertFailedError( \
153 __FILE__, __LINE__, "expected exception " #e_type); \
156 #define ASSERT_ANY_THROW(expr) \
158 catch (...) { break; } \
159 throw ::test::AssertFailedError( \
160 __FILE__, __LINE__, "expected any exception"); \
163 #define ASSERT_NO_THROW(expr) \
166 throw ::test::AssertFailedError( \
167 __FILE__, __LINE__, "no exception expected"); \
TestStatus expected_status
TestBase(const char *, TestStatus)
AssertFailedError(const char *filename, int _line, const char *_errmsg)
std::vector< TestBase * > test_registry_t
const char * what() const
test_registry_t test_registry
static const char * _basename(const char *filename)
backward_ros
Author(s):
autogenerated on Tue Mar 1 2022 23:50:48