summaryrefslogtreecommitdiff
path: root/src/cppunit/TestAssert.cpp
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2001-06-11 18:59:15 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2001-06-11 18:59:15 +0000
commitc7a4dccd9f1b1fadcd47afe482c8a8ff9e05ea8f (patch)
treef0bb90d0fd555bbf07646380c6cab7bf06254620 /src/cppunit/TestAssert.cpp
parent1806e9640462461fba3e1149c7b2c4a31805ec5e (diff)
downloadcppunit-c7a4dccd9f1b1fadcd47afe482c8a8ff9e05ea8f.tar.gz
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.
Diffstat (limited to 'src/cppunit/TestAssert.cpp')
-rw-r--r--src/cppunit/TestAssert.cpp36
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