From c2ac2ac3bcfb30cb8ae4e95e531f1b630b8dd80e Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Wed, 3 Oct 2001 20:16:12 +0000 Subject: Include/cppunit/TestFailure. include/cppunit/TestFailure.cpp : * include/cppunit/TestFailure.h : fixed some constness issues. Added argument to indicate the type of failure to constructor. Added isError(). * include/cppunit/TestListener.h : removed addError(). addFailure() now take a TestFailure as argument. * include/cppunit/TestResult.h : * include/cppunit/TestResult.cpp : removed errors(). Refactored. Fixed some constness issues. Added typedef TestFailures for vector returned by failures(). failures() returns a const reference on the list of failure. added testFailuresTotal(). Constructor can take an optional synchronization object. * include/cppunit/TextTestResult.h : * include/cppunit/TextTestResult.cpp : removed printErrors(). Refactored. Updated to suit new TestResult, errors and failures are reported in the same list. * examples/cppunittest/TestFailureTest.cpp : * examples/cppunittest/TestFailureTest.h : modified to use the new TestFailure constructor. Added one test. * examples/cppunittest/TestListenerTest.cpp: removed addError(). Refactored to suit new TestListener. * examples/cppunittest/TestResultTest.h : * examples/cppunittest/TestResultTest.cpp : modified to suit the new TestResult. --- src/cppunit/TestFailure.cpp | 49 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 11 deletions(-) (limited to 'src/cppunit/TestFailure.cpp') diff --git a/src/cppunit/TestFailure.cpp b/src/cppunit/TestFailure.cpp index 6a48696..0db1628 100644 --- a/src/cppunit/TestFailure.cpp +++ b/src/cppunit/TestFailure.cpp @@ -1,26 +1,53 @@ -#include "cppunit/TestFailure.h" #include "cppunit/Exception.h" #include "cppunit/Test.h" +#include "cppunit/TestFailure.h" namespace CppUnit { -/// Returns a short description of the failure. -std::string -TestFailure::toString () const -{ - return m_failedTest->toString () + ": " + m_thrownException->what (); -} - /// Constructs a TestFailure with the given test and exception. -TestFailure::TestFailure (Test *failedTest, Exception *thrownException) - : m_failedTest (failedTest), m_thrownException (thrownException) +TestFailure::TestFailure( Test *failedTest, + Exception *thrownException, + bool isError ) : + m_failedTest( failedTest ), + m_thrownException( thrownException ), + m_isError( isError ) { } /// Deletes the owned exception. -TestFailure::~TestFailure () +TestFailure::~TestFailure() { delete m_thrownException; } +/// Gets the failed test. +Test * +TestFailure::failedTest() const +{ + return m_failedTest; +} + + +/// Gets the thrown exception. Never \c NULL. +Exception * +TestFailure::thrownException() const +{ + return m_thrownException; +} + + +/// Indicates if the failure is a failed assertion or an error. +bool +TestFailure::isError() const +{ + return m_isError; +} + +/// Returns a short description of the failure. +std::string +TestFailure::toString() const +{ + return m_failedTest->toString() + ": " + m_thrownException->what(); +} + } // namespace CppUnit -- cgit v1.2.1