1#ifndef CPPUNIT_EXTENSIONS_TESTDECORATOR_H 2#define CPPUNIT_EXTENSIONS_TESTDECORATOR_H 3 4#include <cppunit/Portability.h> 5#include <cppunit/Test.h> 6 7namespace CppUnit { 8 9class TestResult; 10 11 12/*! \brief Decorator for Tests. 13 * 14 * TestDecorator provides an alternate means to extend functionality 15 * of a test class without subclassing the test. Instead, one can 16 * subclass the decorater and use it to wrap the test class. 17 * 18 * Does not assume ownership of the test it decorates 19 */ 20class CPPUNIT_API TestDecorator : public Test 21{ 22public: 23 TestDecorator (Test *test); 24 ~TestDecorator (); 25 26 void run (TestResult *result); 27 int countTestCases () const; 28 std::string getName () const; 29 std::string toString () const; 30 31protected: 32 Test *m_test; 33 34private: 35 TestDecorator( const TestDecorator &); 36 void operator =( const TestDecorator & ); 37}; 38 39 40inline TestDecorator::TestDecorator (Test *test) 41{ m_test = test; } 42 43 44inline TestDecorator::~TestDecorator () 45{} 46 47 48inline int TestDecorator::countTestCases () const 49{ return m_test->countTestCases (); } 50 51 52inline void TestDecorator::run (TestResult *result) 53{ m_test->run (result); } 54 55 56inline std::string TestDecorator::toString () const 57{ return m_test->toString (); } 58 59 60inline std::string TestDecorator::getName () const 61{ return m_test->getName(); } 62 63} // namespace CppUnit 64 65#endif 66 67