My Project
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
CxxTest::TestTracker Class Reference

#include <TestTracker.h>

Public Member Functions

virtual ~TestTracker ()
 
const TestDescriptionfixTest (const TestDescription *d) const
 
const SuiteDescriptionfixSuite (const SuiteDescription *d) const
 
const WorldDescriptionfixWorld (const WorldDescription *d) const
 
const TestDescriptiontest () const
 
const SuiteDescriptionsuite () const
 
const WorldDescriptionworld () const
 
bool testFailed () const
 
bool suiteFailed () const
 
bool worldFailed () const
 
unsigned warnings () const
 
unsigned failedTests () const
 
unsigned testFailedAsserts () const
 
unsigned suiteFailedTests () const
 
unsigned failedSuites () const
 
void enterWorld (const WorldDescription &wd)
 
void enterSuite (const SuiteDescription &sd)
 
void enterTest (const TestDescription &td)
 
void leaveTest (const TestDescription &td)
 
void leaveSuite (const SuiteDescription &sd)
 
void leaveWorld (const WorldDescription &wd)
 
void trace (const char *file, unsigned line, const char *expression)
 
void warning (const char *file, unsigned line, const char *expression)
 
void failedTest (const char *file, unsigned line, const char *expression)
 
void failedAssert (const char *file, unsigned line, const char *expression)
 
void failedAssertEquals (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)
 
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)
 
void failedAssertDiffers (const char *file, unsigned line, const char *xStr, const char *yStr, const char *value)
 
void failedAssertLessThan (const char *file, unsigned line, const char *xStr, const char *yStr, const char *x, const char *y)
 
void failedAssertLessThanEquals (const char *file, unsigned line, const char *xStr, const char *yStr, const char *x, const char *y)
 
void failedAssertPredicate (const char *file, unsigned line, const char *predicate, const char *xStr, const char *x)
 
void failedAssertRelation (const char *file, unsigned line, const char *relation, const char *xStr, const char *yStr, const char *x, const char *y)
 
void failedAssertThrows (const char *file, unsigned line, const char *expression, const char *type, bool otherThrown)
 
void failedAssertThrowsNot (const char *file, unsigned line, const char *expression)
 
- Public Member Functions inherited from CxxTest::TestListener
 TestListener ()
 
virtual ~TestListener ()
 
virtual void enterWorld (const WorldDescription &)
 
virtual void enterSuite (const SuiteDescription &)
 
virtual void enterTest (const TestDescription &)
 
virtual void trace (const char *, unsigned, const char *)
 
virtual void warning (const char *, unsigned, const char *)
 
virtual void failedTest (const char *, unsigned, const char *)
 
virtual void failedAssert (const char *, unsigned, const char *)
 
virtual void failedAssertEquals (const char *, unsigned, const char *, const char *, const char *, const char *)
 
virtual void failedAssertSameData (const char *, unsigned, const char *, const char *, const char *, const void *, const void *, unsigned)
 
virtual void failedAssertDelta (const char *, unsigned, const char *, const char *, const char *, const char *, const char *, const char *)
 
virtual void failedAssertDiffers (const char *, unsigned, const char *, const char *, const char *)
 
virtual void failedAssertLessThan (const char *, unsigned, const char *, const char *, const char *, const char *)
 
virtual void failedAssertLessThanEquals (const char *, unsigned, const char *, const char *, const char *, const char *)
 
virtual void failedAssertPredicate (const char *, unsigned, const char *, const char *, const char *)
 
virtual void failedAssertRelation (const char *, unsigned, const char *, const char *, const char *, const char *, const char *)
 
virtual void failedAssertThrows (const char *, unsigned, const char *, const char *, bool)
 
virtual void failedAssertThrowsNot (const char *, unsigned, const char *)
 
virtual void leaveTest (const TestDescription &)
 
virtual void leaveSuite (const SuiteDescription &)
 
virtual void leaveWorld (const WorldDescription &)
 

Static Public Member Functions

static TestTrackertracker ()
 

Private Member Functions

 TestTracker (const TestTracker &)
 
TestTrackeroperator= (const TestTracker &)
 
const TestDescriptiondummyTest () const
 
const SuiteDescriptiondummySuite () const
 
const WorldDescriptiondummyWorld () const
 
void setWorld (const WorldDescription *w)
 
void setSuite (const SuiteDescription *s)
 
void setTest (const TestDescription *t)
 
void countWarning ()
 
void countFailure ()
 
 TestTracker ()
 
void initialize ()
 
void setListener (TestListener *l)
 

Private Attributes

STATIC_VAR bool _created = false
 
TestListener _dummyListener
 
DummyWorldDescription _dummyWorld
 
unsigned _warnings
 
unsigned _failedTests
 
unsigned _testFailedAsserts
 
unsigned _suiteFailedTests
 
unsigned _failedSuites
 
TestListener_l
 
const WorldDescription_world
 
const SuiteDescription_suite
 
const TestDescription_test
 

Friends

class TestRunner
 

Detailed Description

Definition at line 17 of file TestTracker.h.

Constructor & Destructor Documentation

◆ ~TestTracker()

CxxTest::TestTracker::~TestTracker ( )
virtual

Definition at line 18 of file TestTracker.cpp.

19 {
20 }

◆ TestTracker() [1/2]

CxxTest::TestTracker::TestTracker ( const TestTracker )
private

◆ TestTracker() [2/2]

CxxTest::TestTracker::TestTracker ( )
private

Definition at line 10 of file TestTracker.cpp.

11 {
12 if ( !_created ) {
13 initialize();
14 _created = true;
15 }
16 }
STATIC_VAR bool _created
Definition: TestTracker.h:85

Member Function Documentation

◆ countFailure()

void CxxTest::TestTracker::countFailure ( )
private

Definition at line 238 of file TestTracker.cpp.

239 {
240 if ( ++ _testFailedAsserts == 1 ) {
241 ++ _failedTests;
242 if ( ++ _suiteFailedTests == 1 )
243 ++ _failedSuites;
244 }
245 }
unsigned _testFailedAsserts
Definition: TestTracker.h:88
unsigned _failedSuites
Definition: TestTracker.h:88
unsigned _suiteFailedTests
Definition: TestTracker.h:88

◆ countWarning()

void CxxTest::TestTracker::countWarning ( )
private

Definition at line 233 of file TestTracker.cpp.

234 {
235 ++ _warnings;
236 }

◆ dummySuite()

const SuiteDescription & CxxTest::TestTracker::dummySuite ( ) const
private

Definition at line 61 of file TestTracker.cpp.

62 {
63 return dummyWorld().suiteDescription(0);
64 }
const WorldDescription & dummyWorld() const
Definition: TestTracker.cpp:66
virtual const SuiteDescription & suiteDescription(unsigned) const =0

◆ dummyTest()

const TestDescription & CxxTest::TestTracker::dummyTest ( ) const
private

Definition at line 56 of file TestTracker.cpp.

57 {
58 return dummySuite().testDescription(0);
59 }
virtual const TestDescription & testDescription(unsigned) const =0
const SuiteDescription & dummySuite() const
Definition: TestTracker.cpp:61

◆ dummyWorld()

const WorldDescription & CxxTest::TestTracker::dummyWorld ( ) const
private

Definition at line 66 of file TestTracker.cpp.

67 {
68 return _dummyWorld;
69 }
DummyWorldDescription _dummyWorld
Definition: TestTracker.h:87

◆ enterSuite()

void CxxTest::TestTracker::enterSuite ( const SuiteDescription sd)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 83 of file TestTracker.cpp.

84 {
85 setSuite( &sd );
87 _l->enterSuite(sd);
88 }
virtual void enterSuite(const SuiteDescription &)
Definition: TestListener.h:24
void setSuite(const SuiteDescription *s)
TestListener * _l
Definition: TestTracker.h:89

◆ enterTest()

void CxxTest::TestTracker::enterTest ( const TestDescription td)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 90 of file TestTracker.cpp.

91 {
92 setTest( &td );
93 _testFailedAsserts = false;
94 _l->enterTest(td);
95 }
virtual void enterTest(const TestDescription &)
Definition: TestListener.h:25
void setTest(const TestDescription *t)

◆ enterWorld()

void CxxTest::TestTracker::enterWorld ( const WorldDescription wd)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 76 of file TestTracker.cpp.

77 {
78 setWorld( &wd );
80 _l->enterWorld( wd );
81 }
virtual void enterWorld(const WorldDescription &)
Definition: TestListener.h:23
void setWorld(const WorldDescription *w)

◆ failedAssert()

void CxxTest::TestTracker::failedAssert ( const char *  file,
unsigned  line,
const char *  expression 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 132 of file TestTracker.cpp.

133 {
134 countFailure();
135 _l->failedAssert( file, line, expression );
136 }
virtual void failedAssert(const char *, unsigned, const char *)
Definition: TestListener.h:32

◆ failedAssertDelta()

void CxxTest::TestTracker::failedAssertDelta ( const char *  file,
unsigned  line,
const char *  xStr,
const char *  yStr,
const char *  dStr,
const char *  x,
const char *  y,
const char *  d 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 155 of file TestTracker.cpp.

158 {
159 countFailure();
160 _l->failedAssertDelta( file, line, xStr, yStr, dStr, x, y, d );
161 }
Variable x
Definition: cfModGcd.cc:4082
virtual void failedAssertDelta(const char *, unsigned, const char *, const char *, const char *, const char *, const char *, const char *)
Definition: TestListener.h:41
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:53

◆ failedAssertDiffers()

void CxxTest::TestTracker::failedAssertDiffers ( const char *  file,
unsigned  line,
const char *  xStr,
const char *  yStr,
const char *  value 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 163 of file TestTracker.cpp.

166 {
167 countFailure();
168 _l->failedAssertDiffers( file, line, xStr, yStr, value );
169 }
virtual void failedAssertDiffers(const char *, unsigned, const char *, const char *, const char *)
Definition: TestListener.h:45

◆ failedAssertEquals()

void CxxTest::TestTracker::failedAssertEquals ( const char *  file,
unsigned  line,
const char *  xStr,
const char *  yStr,
const char *  x,
const char *  y 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 138 of file TestTracker.cpp.

141 {
142 countFailure();
143 _l->failedAssertEquals( file, line, xStr, yStr, x, y );
144 }
virtual void failedAssertEquals(const char *, unsigned, const char *, const char *, const char *, const char *)
Definition: TestListener.h:34

◆ failedAssertLessThan()

void CxxTest::TestTracker::failedAssertLessThan ( const char *  file,
unsigned  line,
const char *  xStr,
const char *  yStr,
const char *  x,
const char *  y 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 171 of file TestTracker.cpp.

174 {
175 countFailure();
176 _l->failedAssertLessThan( file, line, xStr, yStr, x, y );
177 }
virtual void failedAssertLessThan(const char *, unsigned, const char *, const char *, const char *, const char *)
Definition: TestListener.h:48

◆ failedAssertLessThanEquals()

void CxxTest::TestTracker::failedAssertLessThanEquals ( const char *  file,
unsigned  line,
const char *  xStr,
const char *  yStr,
const char *  x,
const char *  y 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 179 of file TestTracker.cpp.

182 {
183 countFailure();
184 _l->failedAssertLessThanEquals( file, line, xStr, yStr, x, y );
185 }
virtual void failedAssertLessThanEquals(const char *, unsigned, const char *, const char *, const char *, const char *)
Definition: TestListener.h:51

◆ failedAssertPredicate()

void CxxTest::TestTracker::failedAssertPredicate ( const char *  file,
unsigned  line,
const char *  predicate,
const char *  xStr,
const char *  x 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 187 of file TestTracker.cpp.

189 {
190 countFailure();
191 _l->failedAssertPredicate( file, line, predicate, xStr, x );
192 }
virtual void failedAssertPredicate(const char *, unsigned, const char *, const char *, const char *)
Definition: TestListener.h:54

◆ failedAssertRelation()

void CxxTest::TestTracker::failedAssertRelation ( const char *  file,
unsigned  line,
const char *  relation,
const char *  xStr,
const char *  yStr,
const char *  x,
const char *  y 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 194 of file TestTracker.cpp.

197 {
198 countFailure();
199 _l->failedAssertRelation( file, line, relation, xStr, yStr, x, y );
200 }
virtual void failedAssertRelation(const char *, unsigned, const char *, const char *, const char *, const char *, const char *)
Definition: TestListener.h:56

◆ failedAssertSameData()

void CxxTest::TestTracker::failedAssertSameData ( const char *  file,
unsigned  line,
const char *  xStr,
const char *  yStr,
const char *  sizeStr,
const void *  x,
const void *  y,
unsigned  size 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 146 of file TestTracker.cpp.

150 {
151 countFailure();
152 _l->failedAssertSameData( file, line, xStr, yStr, sizeStr, x, y, size );
153 }
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
virtual void failedAssertSameData(const char *, unsigned, const char *, const char *, const char *, const void *, const void *, unsigned)
Definition: TestListener.h:37

◆ failedAssertThrows()

void CxxTest::TestTracker::failedAssertThrows ( const char *  file,
unsigned  line,
const char *  expression,
const char *  type,
bool  otherThrown 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 202 of file TestTracker.cpp.

205 {
206 countFailure();
207 _l->failedAssertThrows( file, line, expression, type, otherThrown );
208 }
virtual void failedAssertThrows(const char *, unsigned, const char *, const char *, bool)
Definition: TestListener.h:59

◆ failedAssertThrowsNot()

void CxxTest::TestTracker::failedAssertThrowsNot ( const char *  file,
unsigned  line,
const char *  expression 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 210 of file TestTracker.cpp.

211 {
212 countFailure();
213 _l->failedAssertThrowsNot( file, line, expression );
214 }
virtual void failedAssertThrowsNot(const char *, unsigned, const char *)
Definition: TestListener.h:62

◆ failedSuites()

unsigned CxxTest::TestTracker::failedSuites ( ) const
inline

Definition at line 40 of file TestTracker.h.

40{ return _failedSuites; }

◆ failedTest()

void CxxTest::TestTracker::failedTest ( const char *  file,
unsigned  line,
const char *  expression 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 126 of file TestTracker.cpp.

127 {
128 countFailure();
129 _l->failedTest( file, line, expression );
130 }
virtual void failedTest(const char *, unsigned, const char *)
Definition: TestListener.h:30

◆ failedTests()

unsigned CxxTest::TestTracker::failedTests ( ) const
inline

Definition at line 37 of file TestTracker.h.

37{ return _failedTests; }

◆ fixSuite()

const SuiteDescription * CxxTest::TestTracker::fixSuite ( const SuiteDescription d) const

Definition at line 46 of file TestTracker.cpp.

47 {
48 return d ? d : &dummySuite();
49 }

◆ fixTest()

const TestDescription * CxxTest::TestTracker::fixTest ( const TestDescription d) const

Definition at line 41 of file TestTracker.cpp.

42 {
43 return d ? d : &dummyTest();
44 }
const TestDescription & dummyTest() const
Definition: TestTracker.cpp:56

◆ fixWorld()

const WorldDescription * CxxTest::TestTracker::fixWorld ( const WorldDescription d) const

Definition at line 51 of file TestTracker.cpp.

52 {
53 return d ? d : &dummyWorld();
54 }

◆ initialize()

void CxxTest::TestTracker::initialize ( )
private

Definition at line 28 of file TestTracker.cpp.

29 {
30 _warnings = 0;
31 _failedTests = 0;
34 _failedSuites = 0;
35 setListener( 0 );
36 _world = 0;
37 _suite = 0;
38 _test = 0;
39 }
const TestDescription * _test
Definition: TestTracker.h:92
const WorldDescription * _world
Definition: TestTracker.h:90
void setListener(TestListener *l)
Definition: TestTracker.cpp:71
const SuiteDescription * _suite
Definition: TestTracker.h:91

◆ leaveSuite()

void CxxTest::TestTracker::leaveSuite ( const SuiteDescription sd)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 103 of file TestTracker.cpp.

104 {
105 _l->leaveSuite( sd );
106 setSuite( 0 );
107 }
virtual void leaveSuite(const SuiteDescription &)
Definition: TestListener.h:65

◆ leaveTest()

void CxxTest::TestTracker::leaveTest ( const TestDescription td)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 97 of file TestTracker.cpp.

98 {
99 _l->leaveTest( td );
100 setTest( 0 );
101 }
virtual void leaveTest(const TestDescription &)
Definition: TestListener.h:64

◆ leaveWorld()

void CxxTest::TestTracker::leaveWorld ( const WorldDescription wd)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 109 of file TestTracker.cpp.

110 {
111 _l->leaveWorld( wd );
112 setWorld( 0 );
113 }
virtual void leaveWorld(const WorldDescription &)
Definition: TestListener.h:66

◆ operator=()

TestTracker & CxxTest::TestTracker::operator= ( const TestTracker )
private

◆ setListener()

void CxxTest::TestTracker::setListener ( TestListener l)
private

Definition at line 71 of file TestTracker.cpp.

72 {
73 _l = l ? l : &_dummyListener;
74 }
int l
Definition: cfEzgcd.cc:100
TestListener _dummyListener
Definition: TestTracker.h:86

◆ setSuite()

void CxxTest::TestTracker::setSuite ( const SuiteDescription s)
private

Definition at line 222 of file TestTracker.cpp.

223 {
224 _suite = fixSuite( s );
225 setTest( 0 );
226 }
const SuiteDescription * fixSuite(const SuiteDescription *d) const
Definition: TestTracker.cpp:46
char * s
Definition: ValueTraits.h:143

◆ setTest()

void CxxTest::TestTracker::setTest ( const TestDescription t)
private

Definition at line 228 of file TestTracker.cpp.

229 {
230 _test = fixTest( t );
231 }
const TestDescription * fixTest(const TestDescription *d) const
Definition: TestTracker.cpp:41

◆ setWorld()

void CxxTest::TestTracker::setWorld ( const WorldDescription w)
private

Definition at line 216 of file TestTracker.cpp.

217 {
218 _world = fixWorld( w );
219 setSuite( 0 );
220 }
const WorldDescription * fixWorld(const WorldDescription *d) const
Definition: TestTracker.cpp:51
const CanonicalForm & w
Definition: facAbsFact.cc:51

◆ suite()

const SuiteDescription & CxxTest::TestTracker::suite ( ) const
inline

Definition at line 29 of file TestTracker.h.

29{ return *_suite; }

◆ suiteFailed()

bool CxxTest::TestTracker::suiteFailed ( ) const
inline

Definition at line 33 of file TestTracker.h.

33{ return (suiteFailedTests() > 0); }
unsigned suiteFailedTests() const
Definition: TestTracker.h:39

◆ suiteFailedTests()

unsigned CxxTest::TestTracker::suiteFailedTests ( ) const
inline

Definition at line 39 of file TestTracker.h.

39{ return _suiteFailedTests; }

◆ test()

const TestDescription & CxxTest::TestTracker::test ( ) const
inline

Definition at line 28 of file TestTracker.h.

28{ return *_test; }

◆ testFailed()

bool CxxTest::TestTracker::testFailed ( ) const
inline

Definition at line 32 of file TestTracker.h.

32{ return (testFailedAsserts() > 0); }
unsigned testFailedAsserts() const
Definition: TestTracker.h:38

◆ testFailedAsserts()

unsigned CxxTest::TestTracker::testFailedAsserts ( ) const
inline

Definition at line 38 of file TestTracker.h.

38{ return _testFailedAsserts; }

◆ trace()

void CxxTest::TestTracker::trace ( const char *  file,
unsigned  line,
const char *  expression 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 115 of file TestTracker.cpp.

116 {
117 _l->trace( file, line, expression );
118 }
virtual void trace(const char *, unsigned, const char *)
Definition: TestListener.h:26

◆ tracker()

TestTracker & CxxTest::TestTracker::tracker ( )
static

Definition at line 22 of file TestTracker.cpp.

23 {
25 return theTracker;
26 }
#define STATIC_INST_VAR
Definition: globaldefs.h:10

◆ warning()

void CxxTest::TestTracker::warning ( const char *  file,
unsigned  line,
const char *  expression 
)
virtual

Reimplemented from CxxTest::TestListener.

Definition at line 120 of file TestTracker.cpp.

121 {
122 countWarning();
123 _l->warning( file, line, expression );
124 }
virtual void warning(const char *, unsigned, const char *)
Definition: TestListener.h:28

◆ warnings()

unsigned CxxTest::TestTracker::warnings ( ) const
inline

Definition at line 36 of file TestTracker.h.

36{ return _warnings; }

◆ world()

const WorldDescription & CxxTest::TestTracker::world ( ) const
inline

Definition at line 30 of file TestTracker.h.

30{ return *_world; }

◆ worldFailed()

bool CxxTest::TestTracker::worldFailed ( ) const
inline

Definition at line 34 of file TestTracker.h.

34{ return (failedSuites() > 0); }
unsigned failedSuites() const
Definition: TestTracker.h:40

Friends And Related Function Documentation

◆ TestRunner

friend class TestRunner
friend

Definition at line 104 of file TestTracker.h.

Field Documentation

◆ _created

bool CxxTest::TestTracker::_created = false
private

Definition at line 85 of file TestTracker.h.

◆ _dummyListener

TestListener CxxTest::TestTracker::_dummyListener
private

Definition at line 86 of file TestTracker.h.

◆ _dummyWorld

DummyWorldDescription CxxTest::TestTracker::_dummyWorld
private

Definition at line 87 of file TestTracker.h.

◆ _failedSuites

unsigned CxxTest::TestTracker::_failedSuites
private

Definition at line 88 of file TestTracker.h.

◆ _failedTests

unsigned CxxTest::TestTracker::_failedTests
private

Definition at line 88 of file TestTracker.h.

◆ _l

TestListener* CxxTest::TestTracker::_l
private

Definition at line 89 of file TestTracker.h.

◆ _suite

const SuiteDescription* CxxTest::TestTracker::_suite
private

Definition at line 91 of file TestTracker.h.

◆ _suiteFailedTests

unsigned CxxTest::TestTracker::_suiteFailedTests
private

Definition at line 88 of file TestTracker.h.

◆ _test

const TestDescription* CxxTest::TestTracker::_test
private

Definition at line 92 of file TestTracker.h.

◆ _testFailedAsserts

unsigned CxxTest::TestTracker::_testFailedAsserts
private

Definition at line 88 of file TestTracker.h.

◆ _warnings

unsigned CxxTest::TestTracker::_warnings
private

Definition at line 88 of file TestTracker.h.

◆ _world

const WorldDescription* CxxTest::TestTracker::_world
private

Definition at line 90 of file TestTracker.h.


The documentation for this class was generated from the following files: