diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-07-16 21:59:22 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-07-16 21:59:22 +0000 |
| commit | 2a31073734be6e44e477079699578820282b7345 (patch) | |
| tree | 70b18c3fc851173fe5fd69a7d844640ab6b780d2 /src/cppunit/Protector.cpp | |
| parent | 251c1ff8aecaa608ef9e6041c2691d369430bf7b (diff) | |
| download | cppunit-2a31073734be6e44e477079699578820282b7345.tar.gz | |
Include/cppunit/Protector.
include/cppunit/Protector.h:
* src/cppunit/Protector.cpp: added. Base class for protectors.
* src/cppunit/DefaultProtector.h:
* src/cppunit/DefaultProtector.cpp: added. Implementation of the default
protector used to catch std::exception and any other exception.
* src/cppunit/ProtectorChain.h:
* src/cppunit/ProtectorChain.cpp: added. Implementation of a chain of
protector, allowing catching custom exception and implementation of
expected exception.
* src/cppunit/TestCase.cpp:
* src/cppunit/TestResult.cpp: updated to use protector.
Diffstat (limited to 'src/cppunit/Protector.cpp')
| -rw-r--r-- | src/cppunit/Protector.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/cppunit/Protector.cpp b/src/cppunit/Protector.cpp new file mode 100644 index 0000000..626829c --- /dev/null +++ b/src/cppunit/Protector.cpp @@ -0,0 +1,41 @@ +#include <cppunit/Exception.h> +#include <cppunit/Message.h> +#include <cppunit/Protector.h> +#include <cppunit/TestResult.h> +#include "ProtectorContext.h" + +CPPUNIT_NS_BEGIN + +Functor::~Functor() +{ +} + + +Protector::~Protector() +{ +} + + +void +Protector::reportTestFailure( const Message &message, + const ProtectorContext &context, + bool isError ) +{ + Message actualMessage; + if ( context.m_shortDescription.empty() ) + actualMessage = message; + else + { + actualMessage = Message( context.m_shortDescription, + message.shortDescription() ); + actualMessage.addDetail( message ); + } + + if ( isError ) + context.m_result->addError( context.m_test, new Exception( message ) ); + else + context.m_result->addFailure( context.m_test, new Exception( message ) ); +} + + +CPPUNIT_NS_END |
