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/TextTestResult.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/cppunit/TextTestResult.cpp') diff --git a/src/cppunit/TextTestResult.cpp b/src/cppunit/TextTestResult.cpp index cbd226f..115da91 100644 --- a/src/cppunit/TextTestResult.cpp +++ b/src/cppunit/TextTestResult.cpp @@ -1,6 +1,7 @@ #include #include "cppunit/TextTestResult.h" #include "cppunit/Exception.h" +#include "cppunit/NotEqualException.h" #include "cppunit/Test.h" #include "estring.h" @@ -82,9 +83,21 @@ TextTestResult::printFailures (std::ostream& stream) << ") " << "test: " << failure->failedTest()->getName() << " " << "line: " << (e ? estring (e->lineNumber ()) : "") << " " - << (e ? e->fileName () : "") << " " - << "\"" << failure->thrownException ()->what () << "\"" - << std::endl; + << (e ? e->fileName () : "") << " "; + + if ( failure->thrownException()->isInstanceOf( NotEqualException::type() ) ) + { + NotEqualException *e = (NotEqualException*)failure->thrownException(); + stream << std::endl + << "expected: " << e->expectedValue() << std::endl + << "but was: " << e->actualValue(); + } + else + { + stream << "\"" << failure->thrownException ()->what () << "\""; + } + + stream << std::endl; i++; } } -- cgit v1.2.1