summaryrefslogtreecommitdiff
path: root/include/cppunit
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2002-07-16 21:59:22 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2002-07-16 21:59:22 +0000
commit2a31073734be6e44e477079699578820282b7345 (patch)
tree70b18c3fc851173fe5fd69a7d844640ab6b780d2 /include/cppunit
parent251c1ff8aecaa608ef9e6041c2691d369430bf7b (diff)
downloadcppunit-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 'include/cppunit')
-rw-r--r--include/cppunit/Makefile.am1
-rw-r--r--include/cppunit/Protector.h39
-rw-r--r--include/cppunit/TestResult.h8
-rw-r--r--include/cppunit/config/config-msvc6.h7
4 files changed, 52 insertions, 3 deletions
diff --git a/include/cppunit/Makefile.am b/include/cppunit/Makefile.am
index 796817c..c743a67 100644
--- a/include/cppunit/Makefile.am
+++ b/include/cppunit/Makefile.am
@@ -13,6 +13,7 @@ libcppunitinclude_HEADERS = \
Message.h \
Outputter.h \
Portability.h \
+ Protector.h \
SourceLine.h \
SynchronizedObject.h \
Test.h \
diff --git a/include/cppunit/Protector.h b/include/cppunit/Protector.h
new file mode 100644
index 0000000..f6073a2
--- /dev/null
+++ b/include/cppunit/Protector.h
@@ -0,0 +1,39 @@
+#ifndef CPPUNIT_PROTECTOR_H
+#define CPPUNIT_PROTECTOR_H
+
+#include <cppunit/Portability.h>
+
+CPPUNIT_NS_BEGIN
+
+
+class Message;
+class ProtectorContext;
+
+
+class CPPUNIT_API Functor
+{
+public:
+ virtual ~Functor();
+
+ virtual bool operator()() const =0;
+};
+
+
+class CPPUNIT_API Protector
+{
+public:
+ virtual ~Protector();
+
+ virtual bool protect( const Functor &functor,
+ const ProtectorContext &context ) =0;
+
+protected:
+ void reportTestFailure( const Message &message,
+ const ProtectorContext &context,
+ bool isError );
+};
+
+CPPUNIT_NS_END
+
+
+#endif // CPPUNIT_PROTECTOR_H \ No newline at end of file
diff --git a/include/cppunit/TestResult.h b/include/cppunit/TestResult.h
index c859001..7168409 100644
--- a/include/cppunit/TestResult.h
+++ b/include/cppunit/TestResult.h
@@ -15,10 +15,13 @@ CPPUNIT_NS_BEGIN
class Exception;
+class Functor;
+class ProtectorChain;
class Test;
class TestFailure;
class TestListener;
+
#if CPPUNIT_NEED_DLL_DECL
// template class CPPUNIT_API std::deque<TestListener *>;
#endif
@@ -67,6 +70,10 @@ public:
virtual void runTest( Test *test );
+ virtual bool protect( const Functor &functor,
+ Test *test,
+ const std::string &shortDescription = std::string("") );
+
protected:
void addFailure( const TestFailure &failure );
@@ -76,6 +83,7 @@ protected:
protected:
typedef CppUnitDeque<TestListener *> TestListeners;
TestListeners m_listeners;
+ ProtectorChain *m_protectorChain;
bool m_stop;
private:
diff --git a/include/cppunit/config/config-msvc6.h b/include/cppunit/config/config-msvc6.h
index 2c48a92..da540cc 100644
--- a/include/cppunit/config/config-msvc6.h
+++ b/include/cppunit/config/config-msvc6.h
@@ -56,9 +56,10 @@
// Uncomment to turn on STL wrapping => use this to test compilation.
// This will make CppUnit subclass std::vector & co to provide default
// parameter.
-//#define CPPUNIT_STD_NEED_ALLOCATOR 1
-//#define CPPUNIT_STD_ALLOCATOR std::allocator<T>
-#define CPPUNIT_NO_NAMESPACE 1
+/*#define CPPUNIT_STD_NEED_ALLOCATOR 1
+#define CPPUNIT_STD_ALLOCATOR std::allocator<T>
+//#define CPPUNIT_NO_NAMESPACE 1
+*/
/* _INCLUDE_CPPUNIT_CONFIG_MSVC6_H */