Go to the documentation of this file.
29 #ifndef CPPTEST_ASSERT_H
30 #define CPPTEST_ASSERT_H
56 #define TEST_FAIL(msg) \
58 assertment(::Test::Source(__FILE__, __LINE__, (msg) != 0 ? #msg : "")); \
59 if (!continue_after_failure()) return; \
84 #define TEST_ASSERT(expr) \
88 assertment(::Test::Source(__FILE__, __LINE__, #expr)); \
89 if (!continue_after_failure()) return; \
104 #define TEST_ASSERT_MSG(expr, msg) \
108 assertment(::Test::Source(__FILE__, __LINE__, msg)); \
109 if (!continue_after_failure()) return; \
126 #define TEST_ASSERT_DELTA(a, b, delta) \
128 if (((b) < (a) - (delta)) || ((b) > (a) + (delta))) \
130 assertment(::Test::Source(__FILE__, __LINE__, \
131 "delta(" #a ", " #b ", " #delta ")" )); \
132 if (!continue_after_failure()) return; \
150 #define TEST_ASSERT_DELTA_MSG(a, b, delta, msg) \
152 if (((b) < (a) - (delta)) || ((b) > (a) + (delta))) \
154 assertment(::Test::Source(__FILE__, __LINE__, msg)); \
155 if (!continue_after_failure()) return; \
171 #define TEST_THROWS(expr, x) \
173 bool __expected = false; \
175 catch (x) { __expected = true; } \
179 assertment(::Test::Source(__FILE__, __LINE__, #expr)); \
180 if (!continue_after_failure()) return; \
197 #define TEST_THROWS_MSG(expr, x, msg) \
199 bool __expected = false; \
201 catch (x) { __expected = true; } \
205 assertment(::Test::Source(__FILE__, __LINE__, msg)); \
206 if (!continue_after_failure()) return; \
221 #define TEST_THROWS_ANYTHING(expr) \
223 bool __expected = false; \
225 catch (...) { __expected = true; } \
228 assertment(::Test::Source(__FILE__, __LINE__, #expr)); \
229 if (!continue_after_failure()) return; \
245 #define TEST_THROWS_ANYTHING_MSG(expr, msg) \
247 bool __expected = false; \
249 catch (...) { __expected = true; } \
252 assertment(::Test::Source(__FILE__, __LINE__, msg)); \
253 if (!continue_after_failure()) return; \
268 #define TEST_THROWS_NOTHING(expr) \
270 bool __expected = true; \
272 catch (...) { __expected = false; } \
275 assertment(::Test::Source(__FILE__, __LINE__, #expr)); \
276 if (!continue_after_failure()) return; \
292 #define TEST_THROWS_NOTHING_MSG(expr, msg) \
294 bool __expected = true; \
296 catch (...) { __expected = false; } \
299 assertment(::Test::Source(__FILE__, __LINE__, msg)); \
300 if (!continue_after_failure()) return; \
330 #endif // #ifndef CPPTEST_ASSERT_H
Time representation.
Definition: cpptest-time.h:44
const std::string & message() const
Definition: source.cpp:71
virtual void assertment(const Source &s)
Definition: collectoroutput.cpp:100
virtual void assertment(const Source &s)
Definition: compileroutput.cpp:109
Test suite output handler.
Definition: cpptest-output.h:56
virtual void test_end(const std::string &name, bool ok, const Time &time)
Definition: collectoroutput.cpp:92
virtual void test_start(const std::string &name)
Definition: collectoroutput.cpp:85
virtual void suite_end(int tests, const std::string &name, const Time &time)
Definition: collectoroutput.cpp:75
Assertment source information.
Definition: cpptest-source.h:43
const std::string & file() const
Definition: source.cpp:55
virtual void finished(int tests, const Time &time)
Definition: collectoroutput.cpp:58
Definition: collectoroutput.cpp:38
virtual void suite_start(int tests, const std::string &name)
Definition: collectoroutput.cpp:65
unsigned int line() const
Definition: source.cpp:63
Supported by: