My Project
RealDescriptions.h
Go to the documentation of this file.
1#ifndef __cxxtest__RealDescriptions_h__
2#define __cxxtest__RealDescriptions_h__
3
4//
5// The "real" description classes
6//
7
9#include <cxxtest/TestSuite.h>
11
12namespace CxxTest
13{
15 {
16 public:
18 RealTestDescription( List &argList, SuiteDescription &argSuite, unsigned argLine, const char *argTestName );
19 void initialize( List &argList, SuiteDescription &argSuite, unsigned argLine, const char *argTestName );
20
21 const char *file() const;
22 unsigned line() const;
23 const char *testName() const;
24 const char *suiteName() const;
25
27 const TestDescription *next() const;
28
29 TestSuite *suite() const;
30
31 bool setUp();
32 void run();
33 bool tearDown();
34
35 private:
38
39 virtual void runTest() = 0;
40
42 unsigned _line;
43 const char *_testName;
44 };
45
47 {
48 public:
50 RealSuiteDescription( const char *argFile, unsigned argLine, const char *argSuiteName, List &argTests );
51
52 void initialize( const char *argFile, unsigned argLine, const char *argSuiteName, List &argTests );
53
54 const char *file() const;
55 unsigned line() const;
56 const char *suiteName() const;
57
59 const TestDescription *firstTest() const;
61 const SuiteDescription *next() const;
62
63 unsigned numTests() const;
64 const TestDescription &testDescription( unsigned i ) const;
65
66 void activateAllTests();
67 bool leaveOnly( const char *testName );
68
69 private:
72
73 const char *_file;
74 unsigned _line;
75 const char *_suiteName;
77
80 };
81
83 {
84 public:
86 StaticSuiteDescription( const char *argFile, unsigned argLine,
87 const char *argSuiteName, TestSuite &argSuite,
88 List &argTests );
89
90 void initialize( const char *argFile, unsigned argLine,
91 const char *argSuiteName, TestSuite &argSuite,
92 List &argTests );
93 TestSuite *suite() const;
94
95 bool setUp();
96 bool tearDown();
97
98 private:
101
102 void doInitialize( TestSuite &argSuite );
103
105 };
106
108 {
109 public:
111 CommonDynamicSuiteDescription( const char *argFile, unsigned argLine,
112 const char *argSuiteName, List &argTests,
113 unsigned argCreateLine, unsigned argDestroyLine );
114
115 void initialize( const char *argFile, unsigned argLine,
116 const char *argSuiteName, List &argTests,
117 unsigned argCreateLine, unsigned argDestroyLine );
118
119 protected:
121
122 private:
123 void doInitialize( unsigned argCreateLine, unsigned argDestroyLine );
124 };
125
126 template<class S>
128 {
129 public:
131 DynamicSuiteDescription( const char *argFile, unsigned argLine,
132 const char *argSuiteName, List &argTests,
133 S *&argSuite, unsigned argCreateLine,
134 unsigned argDestroyLine ) :
135 CommonDynamicSuiteDescription( argFile, argLine, argSuiteName, argTests, argCreateLine, argDestroyLine )
136 {
137 _suite = &argSuite;
138 }
139
140 void initialize( const char *argFile, unsigned argLine,
141 const char *argSuiteName, List &argTests,
142 S *&argSuite, unsigned argCreateLine,
143 unsigned argDestroyLine )
144 {
146 argSuiteName, argTests,
147 argCreateLine, argDestroyLine );
148 _suite = &argSuite;
149 }
150
151 TestSuite *suite() const { return realSuite(); }
152
153 bool setUp();
154 bool tearDown();
155
156 private:
157 S *realSuite() const { return *_suite; }
158 void setSuite( S *s ) { *_suite = s; }
159
161 {
162 setSuite( S::createSuite() );
163 }
164
166 {
167 S *s = realSuite();
168 setSuite( 0 );
169 S::destroySuite( s );
170 }
171
173 };
174
175 template<class S>
177 {
178 _TS_TRY {
179 _TSM_ASSERT_THROWS_NOTHING( file(), _createLine, "Exception thrown from createSuite()", createSuite() );
180 _TSM_ASSERT( file(), _createLine, "createSuite() failed", suite() != 0 );
181 }
182 _TS_CATCH_ABORT( { return false; } );
183
184 return (suite() != 0);
185 }
186
187 template<class S>
189 {
190 if ( !_suite )
191 return true;
192
193 _TS_TRY {
194 _TSM_ASSERT_THROWS_NOTHING( file(), _destroyLine, "destroySuite() failed", destroySuite() );
195 }
196 _TS_CATCH_ABORT( { return false; } );
197
198 return true;
199 }
200
202 {
203 public:
204 static List &suites();
205 unsigned numSuites( void ) const;
206 unsigned numTotalTests( void ) const;
208 const SuiteDescription *firstSuite() const;
209 const SuiteDescription &suiteDescription( unsigned i ) const;
210 void activateAllTests();
211 bool leaveOnly( const char *suiteName, const char *testName = 0 );
212
213 bool setUp();
214 bool tearDown();
215 static void reportError( const char *message );
216 };
217
218 void activateAllTests();
219 bool leaveOnly( const char *suiteName, const char *testName = 0 );
220}
221
222#endif // __cxxtest__RealDescriptions_h__
223
#define _TS_TRY
Definition: TestSuite.h:209
#define _TSM_ASSERT_THROWS_NOTHING(f, l, m, e)
Definition: TestSuite.h:465
#define _TSM_ASSERT(f, l, m, e)
Definition: TestSuite.h:242
#define _TS_CATCH_ABORT(b)
Definition: TestSuite.h:216
int i
Definition: cfEzgcd.cc:132
void initialize(const char *argFile, unsigned argLine, const char *argSuiteName, List &argTests, unsigned argCreateLine, unsigned argDestroyLine)
void doInitialize(unsigned argCreateLine, unsigned argDestroyLine)
void initialize(const char *argFile, unsigned argLine, const char *argSuiteName, List &argTests, S *&argSuite, unsigned argCreateLine, unsigned argDestroyLine)
DynamicSuiteDescription(const char *argFile, unsigned argLine, const char *argSuiteName, List &argTests, S *&argSuite, unsigned argCreateLine, unsigned argDestroyLine)
bool leaveOnly(const char *testName)
const TestDescription & testDescription(unsigned i) const
RealSuiteDescription & operator=(const RealSuiteDescription &)
void initialize(const char *argFile, unsigned argLine, const char *argSuiteName, List &argTests)
STATIC_INST_VAR List _suites
RealSuiteDescription(const RealSuiteDescription &)
RealTestDescription(const RealTestDescription &)
void initialize(List &argList, SuiteDescription &argSuite, unsigned argLine, const char *argTestName)
const char * suiteName() const
const char * testName() const
RealTestDescription & operator=(const RealTestDescription &)
bool leaveOnly(const char *suiteName, const char *testName=0)
const SuiteDescription & suiteDescription(unsigned i) const
static void reportError(const char *message)
unsigned numTotalTests(void) const
StaticSuiteDescription(const StaticSuiteDescription &)
StaticSuiteDescription & operator=(const StaticSuiteDescription &)
void initialize(const char *argFile, unsigned argLine, const char *argSuiteName, TestSuite &argSuite, List &argTests)
void doInitialize(TestSuite &argSuite)
#define STATIC_INST_VAR
Definition: globaldefs.h:10
void message(int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
Definition: kutil.cc:7512
void activateAllTests()
bool leaveOnly(const char *suiteName, const char *testName)
char * s
Definition: ValueTraits.h:143