My Project
Loading...
Searching...
No Matches
TestTracker.cpp
Go to the documentation of this file.
1#ifndef __cxxtest__TestTracker_cpp__
2#define __cxxtest__TestTracker_cpp__
3
5
6namespace CxxTest
7{
8 bool TestTracker::_created = false;
9
11 {
12 if ( !_created ) {
13 initialize();
14 _created = true;
15 }
16 }
17
19 {
20 }
21
23 {
25 return theTracker;
26 }
27
29 {
30 _warnings = 0;
31 _failedTests = 0;
34 _failedSuites = 0;
35 setListener( 0 );
36 _world = 0;
37 _suite = 0;
38 _test = 0;
39 }
40
42 {
43 return d ? d : &dummyTest();
44 }
45
47 {
48 return d ? d : &dummySuite();
49 }
50
52 {
53 return d ? d : &dummyWorld();
54 }
55
57 {
58 return dummySuite().testDescription(0);
59 }
60
62 {
63 return dummyWorld().suiteDescription(0);
64 }
65
67 {
68 return _dummyWorld;
69 }
70
72 {
73 _l = l ? l : &_dummyListener;
74 }
75
77 {
78 setWorld( &wd );
80 _l->enterWorld( wd );
81 }
82
84 {
85 setSuite( &sd );
87 _l->enterSuite(sd);
88 }
89
91 {
92 setTest( &td );
93 _testFailedAsserts = false;
94 _l->enterTest(td);
95 }
96
98 {
99 _l->leaveTest( td );
100 setTest( 0 );
101 }
102
104 {
105 _l->leaveSuite( sd );
106 setSuite( 0 );
107 }
108
110 {
111 _l->leaveWorld( wd );
112 setWorld( 0 );
113 }
114
115 void TestTracker::trace( const char *file, unsigned line, const char *expression )
116 {
117 _l->trace( file, line, expression );
118 }
119
120 void TestTracker::warning( const char *file, unsigned line, const char *expression )
121 {
122 countWarning();
123 _l->warning( file, line, expression );
124 }
125
126 void TestTracker::failedTest( const char *file, unsigned line, const char *expression )
127 {
128 countFailure();
129 _l->failedTest( file, line, expression );
130 }
131
132 void TestTracker::failedAssert( const char *file, unsigned line, const char *expression )
133 {
134 countFailure();
135 _l->failedAssert( file, line, expression );
136 }
137
138 void TestTracker::failedAssertEquals( const char *file, unsigned line,
139 const char *xStr, const char *yStr,
140 const char *x, const char *y )
141 {
142 countFailure();
143 _l->failedAssertEquals( file, line, xStr, yStr, x, y );
144 }
145
146 void TestTracker::failedAssertSameData( const char *file, unsigned line,
147 const char *xStr, const char *yStr,
148 const char *sizeStr, const void *x,
149 const void *y, unsigned size )
150 {
151 countFailure();
152 _l->failedAssertSameData( file, line, xStr, yStr, sizeStr, x, y, size );
153 }
154
155 void TestTracker::failedAssertDelta( const char *file, unsigned line,
156 const char *xStr, const char *yStr, const char *dStr,
157 const char *x, const char *y, const char *d )
158 {
159 countFailure();
160 _l->failedAssertDelta( file, line, xStr, yStr, dStr, x, y, d );
161 }
162
163 void TestTracker::failedAssertDiffers( const char *file, unsigned line,
164 const char *xStr, const char *yStr,
165 const char *value )
166 {
167 countFailure();
168 _l->failedAssertDiffers( file, line, xStr, yStr, value );
169 }
170
171 void TestTracker::failedAssertLessThan( const char *file, unsigned line,
172 const char *xStr, const char *yStr,
173 const char *x, const char *y )
174 {
175 countFailure();
176 _l->failedAssertLessThan( file, line, xStr, yStr, x, y );
177 }
178
179 void TestTracker::failedAssertLessThanEquals( const char *file, unsigned line,
180 const char *xStr, const char *yStr,
181 const char *x, const char *y )
182 {
183 countFailure();
184 _l->failedAssertLessThanEquals( file, line, xStr, yStr, x, y );
185 }
186
187 void TestTracker::failedAssertPredicate( const char *file, unsigned line,
188 const char *predicate, const char *xStr, const char *x )
189 {
190 countFailure();
191 _l->failedAssertPredicate( file, line, predicate, xStr, x );
192 }
193
194 void TestTracker::failedAssertRelation( const char *file, unsigned line,
195 const char *relation, const char *xStr, const char *yStr,
196 const char *x, const char *y )
197 {
198 countFailure();
199 _l->failedAssertRelation( file, line, relation, xStr, yStr, x, y );
200 }
201
202 void TestTracker::failedAssertThrows( const char *file, unsigned line,
203 const char *expression, const char *type,
204 bool otherThrown )
205 {
206 countFailure();
207 _l->failedAssertThrows( file, line, expression, type, otherThrown );
208 }
209
210 void TestTracker::failedAssertThrowsNot( const char *file, unsigned line, const char *expression )
211 {
212 countFailure();
213 _l->failedAssertThrowsNot( file, line, expression );
214 }
215
217 {
218 _world = fixWorld( w );
219 setSuite( 0 );
220 }
221
223 {
224 _suite = fixSuite( s );
225 setTest( 0 );
226 }
227
229 {
230 _test = fixTest( t );
231 }
232
234 {
235 ++ _warnings;
236 }
237
239 {
240 if ( ++ _testFailedAsserts == 1 ) {
241 ++ _failedTests;
242 if ( ++ _suiteFailedTests == 1 )
243 ++ _failedSuites;
244 }
245 }
246};
247
248#endif // __cxxtest__TestTracker_cpp__
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
int l
Definition: cfEzgcd.cc:100
Variable x
Definition: cfModGcd.cc:4082
virtual const TestDescription & testDescription(unsigned) const =0
virtual void failedAssertLessThanEquals(const char *, unsigned, const char *, const char *, const char *, const char *)
Definition: TestListener.h:51
virtual void failedAssertDiffers(const char *, unsigned, const char *, const char *, const char *)
Definition: TestListener.h:45
virtual void failedAssertEquals(const char *, unsigned, const char *, const char *, const char *, const char *)
Definition: TestListener.h:34
virtual void trace(const char *, unsigned, const char *)
Definition: TestListener.h:26
virtual void leaveTest(const TestDescription &)
Definition: TestListener.h:64
virtual void failedAssertLessThan(const char *, unsigned, const char *, const char *, const char *, const char *)
Definition: TestListener.h:48
virtual void failedAssert(const char *, unsigned, const char *)
Definition: TestListener.h:32
virtual void failedAssertDelta(const char *, unsigned, const char *, const char *, const char *, const char *, const char *, const char *)
Definition: TestListener.h:41
virtual void failedAssertRelation(const char *, unsigned, const char *, const char *, const char *, const char *, const char *)
Definition: TestListener.h:56
virtual void failedTest(const char *, unsigned, const char *)
Definition: TestListener.h:30
virtual void failedAssertThrowsNot(const char *, unsigned, const char *)
Definition: TestListener.h:62
virtual void failedAssertThrows(const char *, unsigned, const char *, const char *, bool)
Definition: TestListener.h:59
virtual void enterWorld(const WorldDescription &)
Definition: TestListener.h:23
virtual void warning(const char *, unsigned, const char *)
Definition: TestListener.h:28
virtual void leaveWorld(const WorldDescription &)
Definition: TestListener.h:66
virtual void leaveSuite(const SuiteDescription &)
Definition: TestListener.h:65
virtual void failedAssertPredicate(const char *, unsigned, const char *, const char *, const char *)
Definition: TestListener.h:54
virtual void failedAssertSameData(const char *, unsigned, const char *, const char *, const char *, const void *, const void *, unsigned)
Definition: TestListener.h:37
virtual void enterSuite(const SuiteDescription &)
Definition: TestListener.h:24
virtual void enterTest(const TestDescription &)
Definition: TestListener.h:25
void failedAssertRelation(const char *file, unsigned line, const char *relation, const char *xStr, const char *yStr, const char *x, const char *y)
const TestDescription * _test
Definition: TestTracker.h:92
const WorldDescription * _world
Definition: TestTracker.h:90
const SuiteDescription * fixSuite(const SuiteDescription *d) const
Definition: TestTracker.cpp:46
const WorldDescription * fixWorld(const WorldDescription *d) const
Definition: TestTracker.cpp:51
void trace(const char *file, unsigned line, const char *expression)
void leaveWorld(const WorldDescription &wd)
void enterTest(const TestDescription &td)
Definition: TestTracker.cpp:90
void failedAssertThrows(const char *file, unsigned line, const char *expression, const char *type, bool otherThrown)
void failedAssertPredicate(const char *file, unsigned line, const char *predicate, const char *xStr, const char *x)
void enterWorld(const WorldDescription &wd)
Definition: TestTracker.cpp:76
void failedAssertLessThanEquals(const char *file, unsigned line, const char *xStr, const char *yStr, const char *x, const char *y)
const WorldDescription & dummyWorld() const
Definition: TestTracker.cpp:66
const SuiteDescription & dummySuite() const
Definition: TestTracker.cpp:61
STATIC_VAR bool _created
Definition: TestTracker.h:85
void failedTest(const char *file, unsigned line, const char *expression)
void setListener(TestListener *l)
Definition: TestTracker.cpp:71
void failedAssert(const char *file, unsigned line, const char *expression)
void enterSuite(const SuiteDescription &sd)
Definition: TestTracker.cpp:83
void failedAssertDiffers(const char *file, unsigned line, const char *xStr, const char *yStr, const char *value)
void failedAssertEquals(const char *file, unsigned line, const char *xStr, const char *yStr, const char *x, const char *y)
void setWorld(const WorldDescription *w)
static TestTracker & tracker()
Definition: TestTracker.cpp:22
TestListener _dummyListener
Definition: TestTracker.h:86
void setSuite(const SuiteDescription *s)
unsigned _testFailedAsserts
Definition: TestTracker.h:88
DummyWorldDescription _dummyWorld
Definition: TestTracker.h:87
const TestDescription * fixTest(const TestDescription *d) const
Definition: TestTracker.cpp:41
unsigned _failedSuites
Definition: TestTracker.h:88
TestListener * _l
Definition: TestTracker.h:89
void failedAssertDelta(const char *file, unsigned line, const char *xStr, const char *yStr, const char *dStr, const char *x, const char *y, const char *d)
const TestDescription & dummyTest() const
Definition: TestTracker.cpp:56
void warning(const char *file, unsigned line, const char *expression)
void setTest(const TestDescription *t)
void leaveSuite(const SuiteDescription &sd)
void failedAssertThrowsNot(const char *file, unsigned line, const char *expression)
const SuiteDescription * _suite
Definition: TestTracker.h:91
void leaveTest(const TestDescription &td)
Definition: TestTracker.cpp:97
unsigned _suiteFailedTests
Definition: TestTracker.h:88
void failedAssertLessThan(const char *file, unsigned line, const char *xStr, const char *yStr, const char *x, const char *y)
void failedAssertSameData(const char *file, unsigned line, const char *xStr, const char *yStr, const char *sizeStr, const void *x, const void *y, unsigned size)
virtual const SuiteDescription & suiteDescription(unsigned) const =0
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:53
const CanonicalForm & w
Definition: facAbsFact.cc:51
#define STATIC_INST_VAR
Definition: globaldefs.h:10
char * s
Definition: ValueTraits.h:143