|
|
TestAssertions.h |
| Includes: | <exception> <CPlusTest/TestFailure.h> |
Use the links in the table of contents to the left to access the documentation.
Basic assertion macro.
CPTAssert |
Basic assertion macro.
#define CPTAssert(x) \ do { \ try { \ if (not (x)) { \ throw TestFailure(__FILE__, __LINE__, #x); \ } \ } \ catch (TestFailure& testFaiure) { \ throw; \ } \ catch (std::exception& exception) { \ throw TestFailure(__FILE__, __LINE__, exception.what()); \ } \ catch (...) { \ throw TestFailure(__FILE__, __LINE__, "Uncaught exception"); \ } \ } while (0)
xAn expression that should evaluate to anything non-false on success and false on failure.
The basic assertion macro in CPlusTest records the file, line number, and reason for failure if the passed expression is false. It will also catch exceptions descending from std::exception and report their reason for failure, and will report other thrown exceptions as generic uncaught exceptions.
Last Updated: 2009-08-12