My Project
Loading...
Searching...
No Matches
TestTracker.h
Go to the documentation of this file.
1#ifndef __cxxtest__TestTracker_h__
2#define __cxxtest__TestTracker_h__
3
4//
5// The TestTracker tracks running tests
6// The actual work is done in CountingListenerProxy,
7// but this way avoids cyclic references TestListener<->CountingListenerProxy
8//
12
13namespace CxxTest
14{
15 class TestListener;
16
18 {
19 public:
20 virtual ~TestTracker();
21
22 static TestTracker &tracker();
23
24 const TestDescription *fixTest( const TestDescription *d ) const;
25 const SuiteDescription *fixSuite( const SuiteDescription *d ) const;
26 const WorldDescription *fixWorld( const WorldDescription *d ) const;
27
28 const TestDescription &test() const { return *_test; }
29 const SuiteDescription &suite() const { return *_suite; }
30 const WorldDescription &world() const { return *_world; }
31
32 bool testFailed() const { return (testFailedAsserts() > 0); }
33 bool suiteFailed() const { return (suiteFailedTests() > 0); }
34 bool worldFailed() const { return (failedSuites() > 0); }
35
36 unsigned warnings() const { return _warnings; }
37 unsigned failedTests() const { return _failedTests; }
38 unsigned testFailedAsserts() const { return _testFailedAsserts; }
39 unsigned suiteFailedTests() const { return _suiteFailedTests; }
40 unsigned failedSuites() const { return _failedSuites; }
41
42 void enterWorld( const WorldDescription &wd );
43 void enterSuite( const SuiteDescription &sd );
44 void enterTest( const TestDescription &td );
45 void leaveTest( const TestDescription &td );
46 void leaveSuite( const SuiteDescription &sd );
47 void leaveWorld( const WorldDescription &wd );
48 void trace( const char *file, unsigned line, const char *expression );
49 void warning( const char *file, unsigned line, const char *expression );
50 void failedTest( const char *file, unsigned line, const char *expression );
51 void failedAssert( const char *file, unsigned line, const char *expression );
52 void failedAssertEquals( const char *file, unsigned line,
53 const char *xStr, const char *yStr,
54 const char *x, const char *y );
55 void failedAssertSameData( const char *file, unsigned line,
56 const char *xStr, const char *yStr,
57 const char *sizeStr, const void *x,
58 const void *y, unsigned size );
59 void failedAssertDelta( const char *file, unsigned line,
60 const char *xStr, const char *yStr, const char *dStr,
61 const char *x, const char *y, const char *d );
62 void failedAssertDiffers( const char *file, unsigned line,
63 const char *xStr, const char *yStr,
64 const char *value );
65 void failedAssertLessThan( const char *file, unsigned line,
66 const char *xStr, const char *yStr,
67 const char *x, const char *y );
68 void failedAssertLessThanEquals( const char *file, unsigned line,
69 const char *xStr, const char *yStr,
70 const char *x, const char *y );
71 void failedAssertPredicate( const char *file, unsigned line,
72 const char *predicate, const char *xStr, const char *x );
73 void failedAssertRelation( const char *file, unsigned line,
74 const char *relation, const char *xStr, const char *yStr,
75 const char *x, const char *y );
76 void failedAssertThrows( const char *file, unsigned line,
77 const char *expression, const char *type,
78 bool otherThrown );
79 void failedAssertThrowsNot( const char *file, unsigned line, const char *expression );
80
81 private:
84
93
94 const TestDescription &dummyTest() const;
95 const SuiteDescription &dummySuite() const;
96 const WorldDescription &dummyWorld() const;
97
98 void setWorld( const WorldDescription *w );
99 void setSuite( const SuiteDescription *s );
100 void setTest( const TestDescription *t );
101 void countWarning();
102 void countFailure();
103
104 friend class TestRunner;
105
106 TestTracker();
107 void initialize();
108 void setListener( TestListener *l );
109 };
110
112};
113
114#endif // __cxxtest__TestTracker_h__
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
void failedAssertRelation(const char *file, unsigned line, const char *relation, const char *xStr, const char *yStr, const char *x, const char *y)
TestTracker & operator=(const TestTracker &)
bool suiteFailed() const
Definition: TestTracker.h:33
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
bool testFailed() const
Definition: TestTracker.h:32
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)
TestTracker(const TestTracker &)
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)
unsigned failedSuites() const
Definition: TestTracker.h:40
unsigned warnings() const
Definition: TestTracker.h:36
const WorldDescription & dummyWorld() const
Definition: TestTracker.cpp:66
const SuiteDescription & dummySuite() const
Definition: TestTracker.cpp:61
STATIC_VAR bool _created
Definition: TestTracker.h:85
const SuiteDescription & suite() const
Definition: TestTracker.h:29
const WorldDescription & world() const
Definition: TestTracker.h:30
void failedTest(const char *file, unsigned line, const char *expression)
void setListener(TestListener *l)
Definition: TestTracker.cpp:71
unsigned testFailedAsserts() const
Definition: TestTracker.h:38
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
unsigned failedTests() const
Definition: TestTracker.h:37
void setSuite(const SuiteDescription *s)
unsigned _testFailedAsserts
Definition: TestTracker.h:88
DummyWorldDescription _dummyWorld
Definition: TestTracker.h:87
bool worldFailed() const
Definition: TestTracker.h:34
const TestDescription * fixTest(const TestDescription *d) const
Definition: TestTracker.cpp:41
const TestDescription & test() const
Definition: TestTracker.h:28
unsigned _failedSuites
Definition: TestTracker.h:88
unsigned suiteFailedTests() const
Definition: TestTracker.h:39
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)
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:53
const CanonicalForm & w
Definition: facAbsFact.cc:51
#define STATIC_VAR
Definition: globaldefs.h:7
char * s
Definition: ValueTraits.h:143
TestTracker & tracker()
Definition: TestTracker.h:111