Loading...
Searching...
No Matches
TestTracker.cpp
Go to the documentation of this file.
#ifndef __cxxtest__TestTracker_cpp__
#define __cxxtest__TestTracker_cpp__
#include <cxxtest/TestTracker.h>
namespace CxxTest
{
bool TestTracker::_created = false;
TestTracker::TestTracker()
{
if ( !_created ) {
initialize();
_created = true;
}
}
TestTracker::~TestTracker()
{
}
TestTracker & TestTracker::tracker()
{
STATIC_INST_VAR TestTracker theTracker;
return theTracker;
}
void TestTracker::initialize()
{
_warnings = 0;
_failedTests = 0;
_testFailedAsserts = 0;
_suiteFailedTests = 0;
_failedSuites = 0;
setListener( 0 );
_world = 0;
_suite = 0;
_test = 0;
}
const TestDescription *TestTracker::fixTest( const TestDescription *d ) const
{
return d ? d : &dummyTest();
}
const SuiteDescription *TestTracker::fixSuite( const SuiteDescription *d ) const
{
return d ? d : &dummySuite();
}
const WorldDescription *TestTracker::fixWorld( const WorldDescription *d ) const
{
return d ? d : &dummyWorld();
}
const TestDescription &TestTracker::dummyTest() const
{
return dummySuite().testDescription(0);
}
const SuiteDescription &TestTracker::dummySuite() const
{
return dummyWorld().suiteDescription(0);
}
const WorldDescription &TestTracker::dummyWorld() const
{
return _dummyWorld;
}
void TestTracker::setListener( TestListener *l )
{
_l = l ? l : &_dummyListener;
}
void TestTracker::enterWorld( const WorldDescription &wd )
{
setWorld( &wd );
_warnings = _failedTests = _testFailedAsserts = _suiteFailedTests = _failedSuites = 0;
_l->enterWorld( wd );
}
void TestTracker::enterSuite( const SuiteDescription &sd )
{
setSuite( &sd );
_testFailedAsserts = _suiteFailedTests = 0;
_l->enterSuite(sd);
}
void TestTracker::enterTest( const TestDescription &td )
{
setTest( &td );
_testFailedAsserts = false;
_l->enterTest(td);
}
void TestTracker::leaveTest( const TestDescription &td )
{
_l->leaveTest( td );
setTest( 0 );
}
void TestTracker::leaveSuite( const SuiteDescription &sd )
{
_l->leaveSuite( sd );
setSuite( 0 );
}
void TestTracker::leaveWorld( const WorldDescription &wd )
{
_l->leaveWorld( wd );
setWorld( 0 );
}
void TestTracker::trace( const char *file, unsigned line, const char *expression )
{
_l->trace( file, line, expression );
}
void TestTracker::warning( const char *file, unsigned line, const char *expression )
{
countWarning();
_l->warning( file, line, expression );
}
void TestTracker::failedTest( const char *file, unsigned line, const char *expression )
{
countFailure();
_l->failedTest( file, line, expression );
}
void TestTracker::failedAssert( const char *file, unsigned line, const char *expression )
{
countFailure();
_l->failedAssert( file, line, expression );
}
void TestTracker::failedAssertEquals( const char *file, unsigned line,
const char *xStr, const char *yStr,
const char *x, const char *y )
{
countFailure();
_l->failedAssertEquals( file, line, xStr, yStr, x, y );
}
void TestTracker::failedAssertSameData( const char *file, unsigned line,
const char *xStr, const char *yStr,
const char *sizeStr, const void *x,
const void *y, unsigned size )
{
countFailure();
_l->failedAssertSameData( file, line, xStr, yStr, sizeStr, x, y, size );
}
void 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 )
{
countFailure();
_l->failedAssertDelta( file, line, xStr, yStr, dStr, x, y, d );
}
void TestTracker::failedAssertDiffers( const char *file, unsigned line,
const char *xStr, const char *yStr,
const char *value )
{
countFailure();
_l->failedAssertDiffers( file, line, xStr, yStr, value );
}
void TestTracker::failedAssertLessThan( const char *file, unsigned line,
const char *xStr, const char *yStr,
const char *x, const char *y )
{
countFailure();
_l->failedAssertLessThan( file, line, xStr, yStr, x, y );
}
void TestTracker::failedAssertLessThanEquals( const char *file, unsigned line,
const char *xStr, const char *yStr,
const char *x, const char *y )
{
countFailure();
_l->failedAssertLessThanEquals( file, line, xStr, yStr, x, y );
}
void TestTracker::failedAssertPredicate( const char *file, unsigned line,
const char *predicate, const char *xStr, const char *x )
{
countFailure();
_l->failedAssertPredicate( file, line, predicate, xStr, x );
}
void TestTracker::failedAssertRelation( const char *file, unsigned line,
const char *relation, const char *xStr, const char *yStr,
const char *x, const char *y )
{
countFailure();
_l->failedAssertRelation( file, line, relation, xStr, yStr, x, y );
}
void TestTracker::failedAssertThrows( const char *file, unsigned line,
const char *expression, const char *type,
bool otherThrown )
{
countFailure();
_l->failedAssertThrows( file, line, expression, type, otherThrown );
}
void TestTracker::failedAssertThrowsNot( const char *file, unsigned line, const char *expression )
{
countFailure();
_l->failedAssertThrowsNot( file, line, expression );
}
void TestTracker::setWorld( const WorldDescription *w )
{
_world = fixWorld( w );
setSuite( 0 );
}
void TestTracker::setSuite( const SuiteDescription *s )
{
_suite = fixSuite( s );
setTest( 0 );
}
void TestTracker::setTest( const TestDescription *t )
{
_test = fixTest( t );
}
void TestTracker::countWarning()
{
++ _warnings;
}
void TestTracker::countFailure()
{
if ( ++ _testFailedAsserts == 1 ) {
++ _failedTests;
if ( ++ _suiteFailedTests == 1 )
++ _failedSuites;
}
}
};
#endif // __cxxtest__TestTracker_cpp__
TestTracker.h
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600
l
int l
Definition cfEzgcd.cc:100
x
Variable x
Definition cfModGcd.cc:4090
CxxTest::SuiteDescription
Definition Descriptions.h:32
CxxTest::SuiteDescription::testDescription
virtual const TestDescription & testDescription(unsigned) const =0
CxxTest::TestDescription
Definition Descriptions.h:16
CxxTest::TestListener::TestListener
TestListener()
Definition TestListener.h:20
CxxTest::TestTracker::failedAssertRelation
void failedAssertRelation(const char *file, unsigned line, const char *relation, const char *xStr, const char *yStr, const char *x, const char *y)
Definition TestTracker.cpp:194
CxxTest::TestTracker::_failedTests
unsigned _failedTests
Definition TestTracker.h:88
CxxTest::TestTracker::~TestTracker
virtual ~TestTracker()
Definition TestTracker.cpp:18
CxxTest::TestTracker::_test
const TestDescription * _test
Definition TestTracker.h:92
CxxTest::TestTracker::_world
const WorldDescription * _world
Definition TestTracker.h:90
CxxTest::TestTracker::fixSuite
const SuiteDescription * fixSuite(const SuiteDescription *d) const
Definition TestTracker.cpp:46
CxxTest::TestTracker::fixWorld
const WorldDescription * fixWorld(const WorldDescription *d) const
Definition TestTracker.cpp:51
CxxTest::TestTracker::trace
void trace(const char *file, unsigned line, const char *expression)
Definition TestTracker.cpp:115
CxxTest::TestTracker::leaveWorld
void leaveWorld(const WorldDescription &wd)
Definition TestTracker.cpp:109
CxxTest::TestTracker::enterTest
void enterTest(const TestDescription &td)
Definition TestTracker.cpp:90
CxxTest::TestTracker::_warnings
unsigned _warnings
Definition TestTracker.h:88
CxxTest::TestTracker::countWarning
void countWarning()
Definition TestTracker.cpp:233
CxxTest::TestTracker::failedAssertThrows
void failedAssertThrows(const char *file, unsigned line, const char *expression, const char *type, bool otherThrown)
Definition TestTracker.cpp:202
CxxTest::TestTracker::failedAssertPredicate
void failedAssertPredicate(const char *file, unsigned line, const char *predicate, const char *xStr, const char *x)
Definition TestTracker.cpp:187
CxxTest::TestTracker::TestTracker
TestTracker(const TestTracker &)
CxxTest::TestTracker::enterWorld
void enterWorld(const WorldDescription &wd)
Definition TestTracker.cpp:76
CxxTest::TestTracker::TestTracker
TestTracker()
Definition TestTracker.cpp:10
CxxTest::TestTracker::failedAssertLessThanEquals
void failedAssertLessThanEquals(const char *file, unsigned line, const char *xStr, const char *yStr, const char *x, const char *y)
Definition TestTracker.cpp:179
CxxTest::TestTracker::countFailure
void countFailure()
Definition TestTracker.cpp:238
CxxTest::TestTracker::dummyWorld
const WorldDescription & dummyWorld() const
Definition TestTracker.cpp:66
CxxTest::TestTracker::dummySuite
const SuiteDescription & dummySuite() const
Definition TestTracker.cpp:61
CxxTest::TestTracker::_created
STATIC_VAR bool _created
Definition TestTracker.h:85
CxxTest::TestTracker::failedTest
void failedTest(const char *file, unsigned line, const char *expression)
Definition TestTracker.cpp:126
CxxTest::TestTracker::setListener
void setListener(TestListener *l)
Definition TestTracker.cpp:71
CxxTest::TestTracker::failedAssert
void failedAssert(const char *file, unsigned line, const char *expression)
Definition TestTracker.cpp:132
CxxTest::TestTracker::enterSuite
void enterSuite(const SuiteDescription &sd)
Definition TestTracker.cpp:83
CxxTest::TestTracker::failedAssertDiffers
void failedAssertDiffers(const char *file, unsigned line, const char *xStr, const char *yStr, const char *value)
Definition TestTracker.cpp:163
CxxTest::TestTracker::failedAssertEquals
void failedAssertEquals(const char *file, unsigned line, const char *xStr, const char *yStr, const char *x, const char *y)
Definition TestTracker.cpp:138
CxxTest::TestTracker::setWorld
void setWorld(const WorldDescription *w)
Definition TestTracker.cpp:216
CxxTest::TestTracker::tracker
static TestTracker & tracker()
Definition TestTracker.cpp:22
CxxTest::TestTracker::_dummyListener
TestListener _dummyListener
Definition TestTracker.h:86
CxxTest::TestTracker::setSuite
void setSuite(const SuiteDescription *s)
Definition TestTracker.cpp:222
CxxTest::TestTracker::_testFailedAsserts
unsigned _testFailedAsserts
Definition TestTracker.h:88
CxxTest::TestTracker::_dummyWorld
DummyWorldDescription _dummyWorld
Definition TestTracker.h:87
CxxTest::TestTracker::initialize
void initialize()
Definition TestTracker.cpp:28
CxxTest::TestTracker::fixTest
const TestDescription * fixTest(const TestDescription *d) const
Definition TestTracker.cpp:41
CxxTest::TestTracker::_failedSuites
unsigned _failedSuites
Definition TestTracker.h:88
CxxTest::TestTracker::_l
TestListener * _l
Definition TestTracker.h:89
CxxTest::TestTracker::failedAssertDelta
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)
Definition TestTracker.cpp:155
CxxTest::TestTracker::dummyTest
const TestDescription & dummyTest() const
Definition TestTracker.cpp:56
CxxTest::TestTracker::warning
void warning(const char *file, unsigned line, const char *expression)
Definition TestTracker.cpp:120
CxxTest::TestTracker::setTest
void setTest(const TestDescription *t)
Definition TestTracker.cpp:228
CxxTest::TestTracker::leaveSuite
void leaveSuite(const SuiteDescription &sd)
Definition TestTracker.cpp:103
CxxTest::TestTracker::failedAssertThrowsNot
void failedAssertThrowsNot(const char *file, unsigned line, const char *expression)
Definition TestTracker.cpp:210
CxxTest::TestTracker::_suite
const SuiteDescription * _suite
Definition TestTracker.h:91
CxxTest::TestTracker::leaveTest
void leaveTest(const TestDescription &td)
Definition TestTracker.cpp:97
CxxTest::TestTracker::_suiteFailedTests
unsigned _suiteFailedTests
Definition TestTracker.h:88
CxxTest::TestTracker::failedAssertLessThan
void failedAssertLessThan(const char *file, unsigned line, const char *xStr, const char *yStr, const char *x, const char *y)
Definition TestTracker.cpp:171
CxxTest::TestTracker::failedAssertSameData
void failedAssertSameData(const char *file, unsigned line, const char *xStr, const char *yStr, const char *sizeStr, const void *x, const void *y, unsigned size)
Definition TestTracker.cpp:146
CxxTest::WorldDescription
Definition Descriptions.h:54
CxxTest::WorldDescription::suiteDescription
virtual const SuiteDescription & suiteDescription(unsigned) const =0
y
const CanonicalForm int const CFList const Variable & y
Definition facAbsFact.cc:53
w
const CanonicalForm & w
Definition facAbsFact.cc:51
STATIC_INST_VAR
#define STATIC_INST_VAR
Definition globaldefs.h:10
CxxTest
Definition Descriptions.cpp:7
CxxTest::s
char * s
Definition ValueTraits.h:143