CppUnit - The Unit Testing Library

CppUnit project page | FAQ

Protector.h
Go to the documentation of this file.
1#ifndef CPPUNIT_PROTECTOR_H
2#define CPPUNIT_PROTECTOR_H
3
4#include <cppunit/SourceLine.h>
5
6 CPPUNIT_NS_BEGIN
7
8class Exception;
9class Message;
10class ProtectorContext;
11class TestResult;
12
13
14 class CPPUNIT_API Functor
15{
16public:
17 virtual ~Functor();
18
19 virtual bool operator()() const =0;
20};
21
22
47 class CPPUNIT_API Protector
48{
49public:
50 virtual ~Protector();
51
52 virtual bool protect( const Functor &functor,
53 const ProtectorContext &context ) =0;
54
55protected:
56 void reportError( const ProtectorContext &context,
57 const Exception &error ) const;
58
59 void reportError( const ProtectorContext &context,
60 const Message &message,
61 const SourceLine &sourceLine = SourceLine() ) const;
62
63 void reportFailure( const ProtectorContext &context,
64 const Exception &failure ) const;
65
66 Message actualMessage( const Message &message,
67 const ProtectorContext &context ) const;
68};
69
70
76 class CPPUNIT_API ProtectorGuard
77{
78public:
80 ProtectorGuard( TestResult *result,
81 Protector *protector );
82
84 ~ProtectorGuard();
85
86private:
87 ProtectorGuard( const ProtectorGuard& ); /* not copyable */
88 ProtectorGuard& operator=( const ProtectorGuard& ); /* not assignable */
89 TestResult *m_result;
90};
91
92 CPPUNIT_NS_END
93
94
95#endif // CPPUNIT_PROTECTOR_H
96
CPPUNIT_API
#define CPPUNIT_API
Definition: CppUnitApi.h:27
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition: Portability.h:106
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition: Portability.h:105
SourceLine.h
Exception
Exceptions thrown by failed assertions.
Definition: Exception.h:20
Functor
Definition: Protector.h:15
Functor::operator()
virtual bool operator()() const =0
Message
Message associated to an Exception.A message is composed of two items:
Definition: Message.h:35
ProtectorContext
Protector context (Implementation). Implementation detail.
Definition: ProtectorContext.h:18
ProtectorGuard
Scoped protector push to TestResult.
Definition: Protector.h:77
ProtectorGuard::m_result
TestResult * m_result
Definition: Protector.h:89
ProtectorGuard::ProtectorGuard
ProtectorGuard(const ProtectorGuard &)
ProtectorGuard::operator=
ProtectorGuard & operator=(const ProtectorGuard &)
Protector
Protects one or more test case run.
Definition: Protector.h:48
Protector::protect
virtual bool protect(const Functor &functor, const ProtectorContext &context)=0
SourceLine
Represents a source line location.
Definition: SourceLine.h:31
TestResult
Manages TestListener.
Definition: TestResult.h:48

| Send comments to: CppUnit Developers