summaryrefslogtreecommitdiff
path: root/examples/cppunittest/TestSetUpTest.h
blob: 854be0ac187f86e9615bd60281c9cbb827526652 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef TESTSETUPTEST_H
#define TESTSETUPTEST_H

#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestSetUp.h>
#include "FailingTestCase.h"


class TestSetUpTest : public CppUnit::TestCase
{
  CPPUNIT_TEST_SUITE( TestSetUpTest );
  CPPUNIT_TEST( testRun );
  CPPUNIT_TEST_SUITE_END();

public:
  TestSetUpTest();
  virtual ~TestSetUpTest();

  virtual void setUp();
  virtual void tearDown();

  void testRun();

private:
  class SetUp : public CppUnit::TestSetUp
  {
  public:
    SetUp( CppUnit::Test *test ) : 
        TestSetUp( test ),
        m_setUpCalled( false ),
        m_tearDownCalled( false )
    {
    }

    void setUp() 
    {
      m_setUpCalled = true;
    }

    void tearDown()
    {
      m_tearDownCalled = true;
    }

    bool m_setUpCalled;
    bool m_tearDownCalled;
  };

  TestSetUpTest( const TestSetUpTest &copy );
  void operator =( const TestSetUpTest &copy );

private:
  SetUp *m_setUp;
  FailingTestCase *m_test;
};



#endif  // TESTSETUPTEST_H