diff options
Diffstat (limited to 'src/cppunit/TestAssert.cpp')
| -rw-r--r-- | src/cppunit/TestAssert.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/cppunit/TestAssert.cpp b/src/cppunit/TestAssert.cpp new file mode 100644 index 0000000..2750023 --- /dev/null +++ b/src/cppunit/TestAssert.cpp @@ -0,0 +1,36 @@ +#include <cmath> + +#include "cppunit/TestAssert.h" +#include "estring.h" + +namespace CppUnit { + +/// Check for a failed general assertion +void TestAssert::assertImplementation (bool condition, + std::string conditionExpression, + long lineNumber, + std::string fileName) +{ + if (!condition) + throw Exception (conditionExpression, + lineNumber, + fileName); +} + + +/// Check for a failed equality assertion +void TestAssert::assertEquals (double expected, + double actual, + double delta, + long lineNumber, + std::string fileName) +{ + if (fabs (expected - actual) > delta) + assertImplementation (false, + notEqualsMessage(expected, actual), + lineNumber, + fileName); +} + + +} // namespace TestAssert |
