From bf78ed5d2c0f623efd08c277f97b240f2fef7ee6 Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Tue, 12 Jun 2001 05:59:26 +0000 Subject: Include/cppunit/NotEqualException. include/cppunit/NotEqualException.h * src/cppunit/NotEqualException.h: Fixed constructor and operator = (aren't unit test nice?). Added methods expectedValue() and actualValue(). * include/cppunit/TestAssert.h: * src/cppunit/TestAssert.cpp: Use NotEqualException to report equality failure. * src/cppunit/TestResult.cpp: Report expect/was on different line for assertEquals failure. * examples/cppunittest/NotEqualExceptionTest.*: added unit tests for NotEqualException. --- src/cppunit/TestAssert.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/cppunit/TestAssert.cpp') diff --git a/src/cppunit/TestAssert.cpp b/src/cppunit/TestAssert.cpp index 2750023..f93c19b 100644 --- a/src/cppunit/TestAssert.cpp +++ b/src/cppunit/TestAssert.cpp @@ -2,6 +2,7 @@ #include "cppunit/TestAssert.h" #include "estring.h" +#include namespace CppUnit { @@ -18,6 +19,16 @@ void TestAssert::assertImplementation (bool condition, } +/// Reports failed equality +void TestAssert::assertNotEqualImplementation( std::string expected, + std::string actual, + long lineNumber, + std::string fileName ) +{ + throw NotEqualException( expected, actual, lineNumber, fileName ); +} + + /// Check for a failed equality assertion void TestAssert::assertEquals (double expected, double actual, @@ -26,10 +37,10 @@ void TestAssert::assertEquals (double expected, std::string fileName) { if (fabs (expected - actual) > delta) - assertImplementation (false, - notEqualsMessage(expected, actual), - lineNumber, - fileName); + assertNotEqualImplementation( assertion_traits::toString(expected), + assertion_traits::toString(actual), + lineNumber, + fileName ); } -- cgit v1.2.1