From c7a4dccd9f1b1fadcd47afe482c8a8ff9e05ea8f Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Mon, 11 Jun 2001 18:59:15 +0000 Subject: Include/cppunit/NotEqualException. include/cppunit/NotEqualException.cpp: addded, exception to be used with assertEquals(). * src/cppunit/RepeatedTest.cpp: added to reduce header dependency (TestResult.h was missing). * src/cppunit/TestAssert.cpp: added to put non template functions there. * src/cppunit/TestCase.cpp: added std:: prefix to catch (exception& e). Integrated a modified version of Tim Jansen patch (#403745) for TestCase to make the unit test (TestCaseTest) pass. If the setUp() fail then neither the runTest() nor the tearDown() method is called. --- src/cppunit/TestAssert.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/cppunit/TestAssert.cpp (limited to 'src/cppunit/TestAssert.cpp') 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 + +#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 -- cgit v1.2.1