1 #ifndef TESTSETUPTEST_H 2 #define TESTSETUPTEST_H 3 4 #include <cppunit/extensions/HelperMacros.h> 5 #include <cppunit/extensions/TestSetUp.h> 6 7 8 class TestSetUpTest : public CPPUNIT_NS::TestFixture 9 { 10 CPPUNIT_TEST_SUITE( TestSetUpTest ); 11 CPPUNIT_TEST( testRun ); 12 CPPUNIT_TEST_SUITE_END(); 13 14 public: 15 TestSetUpTest(); 16 virtual ~TestSetUpTest(); 17 18 void setUp(); 19 void tearDown(); 20 21 void testRun(); 22 23 private: 24 class MockSetUp : public CPPUNIT_NS::TestSetUp 25 { 26 public: MockSetUp(CPPUNIT_NS::Test * test)27 MockSetUp( CPPUNIT_NS::Test *test ) 28 : CPPUNIT_NS::TestSetUp( test ) 29 , m_setUpCalled( false ) 30 , m_tearDownCalled( false ) 31 { 32 } 33 setUp()34 void setUp() 35 { 36 m_setUpCalled = true; 37 } 38 tearDown()39 void tearDown() 40 { 41 m_tearDownCalled = true; 42 } 43 verify()44 void verify() 45 { 46 CPPUNIT_ASSERT( m_setUpCalled ); 47 CPPUNIT_ASSERT( m_tearDownCalled ); 48 } 49 50 private: 51 bool m_setUpCalled; 52 bool m_tearDownCalled; 53 }; 54 55 TestSetUpTest( const TestSetUpTest © ); 56 void operator =( const TestSetUpTest © ); 57 58 private: 59 }; 60 61 62 63 #endif // TESTSETUPTEST_H 64