Go to the documentation of this file. 30 #ifndef CPPTEST_ASSERT_H 31 #define CPPTEST_ASSERT_H 59 #define TEST_FAIL(msg) \ 61 assertment(::Test::Source(__FILE__, __LINE__, (msg) != 0 ? #msg : "")); \ 62 if (!continue_after_failure()) return; \ 87 #define TEST_ASSERT(expr) \ 91 assertment(::Test::Source(__FILE__, __LINE__, #expr)); \ 92 if (!continue_after_failure()) return; \ 107 #define TEST_ASSERT_MSG(expr, msg) \ 111 assertment(::Test::Source(__FILE__, __LINE__, msg)); \ 112 if (!continue_after_failure()) return; \ 133 #define TEST_ASSERT_EQUALS(expected, got) \ 135 if (!((got) == (expected))) \ 137 std::stringstream tmpstream; \ 138 tmpstream << "Got " << (got) << ", expected " << (expected);\ 139 assertment(::Test::Source(__FILE__, __LINE__, \ 140 tmpstream.str().c_str())); \ 141 if (!continue_after_failure()) return; \ 162 #define TEST_ASSERT_EQUALS_OBJ(expected, got) \ 164 if (!((got) == (expected))) \ 166 std::stringstream tmpstream; \ 167 tmpstream << #expected << " object not equal to "; \ 168 tmpstream << #got << " object."; \ 169 assertment(::Test::Source(__FILE__, __LINE__, \ 170 tmpstream.str().c_str())); \ 171 if (!continue_after_failure()) return; \ 190 #define TEST_ASSERT_EQUALS_MSG(expected, got, msg) \ 192 if (!((got) == (expected))) \ 194 std::stringstream tmpstream; \ 195 tmpstream << (msg) << ": "; \ 196 tmpstream << "Got " << (got) << ", expected " << (expected);\ 197 assertment(::Test::Source(__FILE__, __LINE__, \ 198 tmpstream.str().c_str())); \ 199 if (!continue_after_failure()) return; \ 216 #define TEST_ASSERT_DELTA(a, b, delta) \ 218 if (((b) < (a) - (delta)) || ((b) > (a) + (delta))) \ 220 assertment(::Test::Source(__FILE__, __LINE__, \ 221 "delta(" #a ", " #b ", " #delta ")" )); \ 222 if (!continue_after_failure()) return; \ 240 #define TEST_ASSERT_DELTA_MSG(a, b, delta, msg) \ 242 if (((b) < (a) - (delta)) || ((b) > (a) + (delta))) \ 244 assertment(::Test::Source(__FILE__, __LINE__, msg)); \ 245 if (!continue_after_failure()) return; \ 261 #define TEST_THROWS(expr, x) \ 263 bool __expected = false; \ 265 catch (x) { __expected = true; } \ 269 assertment(::Test::Source(__FILE__, __LINE__, #expr)); \ 270 if (!continue_after_failure()) return; \ 287 #define TEST_THROWS_MSG(expr, x, msg) \ 289 bool __expected = false; \ 291 catch (x) { __expected = true; } \ 295 assertment(::Test::Source(__FILE__, __LINE__, msg)); \ 296 if (!continue_after_failure()) return; \ 311 #define TEST_THROWS_ANYTHING(expr) \ 313 bool __expected = false; \ 315 catch (...) { __expected = true; } \ 318 assertment(::Test::Source(__FILE__, __LINE__, #expr)); \ 319 if (!continue_after_failure()) return; \ 335 #define TEST_THROWS_ANYTHING_MSG(expr, msg) \ 337 bool __expected = false; \ 339 catch (...) { __expected = true; } \ 342 assertment(::Test::Source(__FILE__, __LINE__, msg)); \ 343 if (!continue_after_failure()) return; \ 358 #define TEST_THROWS_NOTHING(expr) \ 360 bool __expected = true; \ 362 catch (...) { __expected = false; } \ 365 assertment(::Test::Source(__FILE__, __LINE__, #expr)); \ 366 if (!continue_after_failure()) return; \ 382 #define TEST_THROWS_NOTHING_MSG(expr, msg) \ 384 bool __expected = true; \ 386 catch (...) { __expected = false; } \ 389 assertment(::Test::Source(__FILE__, __LINE__, msg)); \ 390 if (!continue_after_failure()) return; \ 423 #endif // #ifndef CPPTEST_ASSERT_H