Loading...
Searching...
No Matches
RealDescriptions.h
Go to the documentation of this file.
#ifndef __cxxtest__RealDescriptions_h__
#define __cxxtest__RealDescriptions_h__
//
// The "real" description classes
//
#include <cxxtest/Descriptions.h>
#include <cxxtest/TestSuite.h>
#include <cxxtest/GlobalFixture.h>
namespace CxxTest
{
class RealTestDescription : public TestDescription
{
public:
RealTestDescription();
RealTestDescription( List &argList, SuiteDescription &argSuite, unsigned argLine, const char *argTestName );
void initialize( List &argList, SuiteDescription &argSuite, unsigned argLine, const char *argTestName );
const char *file() const;
unsigned line() const;
const char *testName() const;
const char *suiteName() const;
TestDescription *next();
const TestDescription *next() const;
TestSuite *suite() const;
bool setUp();
void run();
bool tearDown();
private:
RealTestDescription( const RealTestDescription & );
RealTestDescription &operator=( const RealTestDescription & );
virtual void runTest() = 0;
SuiteDescription *_suite;
unsigned _line;
const char *_testName;
};
class RealSuiteDescription : public SuiteDescription
{
public:
RealSuiteDescription();
RealSuiteDescription( const char *argFile, unsigned argLine, const char *argSuiteName, List &argTests );
void initialize( const char *argFile, unsigned argLine, const char *argSuiteName, List &argTests );
const char *file() const;
unsigned line() const;
const char *suiteName() const;
TestDescription *firstTest();
const TestDescription *firstTest() const;
SuiteDescription *next();
const SuiteDescription *next() const;
unsigned numTests() const;
const TestDescription &testDescription( unsigned i ) const;
void activateAllTests();
bool leaveOnly( const char *testName );
private:
RealSuiteDescription( const RealSuiteDescription & );
RealSuiteDescription &operator=( const RealSuiteDescription & );
const char *_file;
unsigned _line;
const char *_suiteName;
List *_tests;
STATIC_INST_VAR List _suites;
friend class RealWorldDescription;
};
class StaticSuiteDescription : public RealSuiteDescription
{
public:
StaticSuiteDescription();
StaticSuiteDescription( const char *argFile, unsigned argLine,
const char *argSuiteName, TestSuite &argSuite,
List &argTests );
void initialize( const char *argFile, unsigned argLine,
const char *argSuiteName, TestSuite &argSuite,
List &argTests );
TestSuite *suite() const;
bool setUp();
bool tearDown();
private:
StaticSuiteDescription( const StaticSuiteDescription & );
StaticSuiteDescription &operator=( const StaticSuiteDescription & );
void doInitialize( TestSuite &argSuite );
TestSuite *_suite;
};
class CommonDynamicSuiteDescription : public RealSuiteDescription
{
public:
CommonDynamicSuiteDescription();
CommonDynamicSuiteDescription( const char *argFile, unsigned argLine,
const char *argSuiteName, List &argTests,
unsigned argCreateLine, unsigned argDestroyLine );
void initialize( const char *argFile, unsigned argLine,
const char *argSuiteName, List &argTests,
unsigned argCreateLine, unsigned argDestroyLine );
protected:
unsigned _createLine, _destroyLine;
private:
void doInitialize( unsigned argCreateLine, unsigned argDestroyLine );
};
template<class S>
class DynamicSuiteDescription : public CommonDynamicSuiteDescription
{
public:
DynamicSuiteDescription() {}
DynamicSuiteDescription( const char *argFile, unsigned argLine,
const char *argSuiteName, List &argTests,
S *&argSuite, unsigned argCreateLine,
unsigned argDestroyLine ) :
CommonDynamicSuiteDescription( argFile, argLine, argSuiteName, argTests, argCreateLine, argDestroyLine )
{
_suite = &argSuite;
}
void initialize( const char *argFile, unsigned argLine,
const char *argSuiteName, List &argTests,
S *&argSuite, unsigned argCreateLine,
unsigned argDestroyLine )
{
CommonDynamicSuiteDescription::initialize( argFile, argLine,
argSuiteName, argTests,
argCreateLine, argDestroyLine );
_suite = &argSuite;
}
TestSuite *suite() const { return realSuite(); }
bool setUp();
bool tearDown();
private:
S *realSuite() const { return *_suite; }
void setSuite( S *s ) { *_suite = s; }
void createSuite()
{
setSuite( S::createSuite() );
}
void destroySuite()
{
S *s = realSuite();
setSuite( 0 );
S::destroySuite( s );
}
S **_suite;
};
template<class S>
bool DynamicSuiteDescription<S>::setUp()
{
_TS_TRY {
_TSM_ASSERT_THROWS_NOTHING( file(), _createLine, "Exception thrown from createSuite()", createSuite() );
_TSM_ASSERT( file(), _createLine, "createSuite() failed", suite() != 0 );
}
_TS_CATCH_ABORT( { return false; } );
return (suite() != 0);
}
template<class S>
bool DynamicSuiteDescription<S>::tearDown()
{
if ( !_suite )
return true;
_TS_TRY {
_TSM_ASSERT_THROWS_NOTHING( file(), _destroyLine, "destroySuite() failed", destroySuite() );
}
_TS_CATCH_ABORT( { return false; } );
return true;
}
class RealWorldDescription : public WorldDescription
{
public:
static List &suites();
unsigned numSuites( void ) const;
unsigned numTotalTests( void ) const;
SuiteDescription *firstSuite();
const SuiteDescription *firstSuite() const;
const SuiteDescription &suiteDescription( unsigned i ) const;
void activateAllTests();
bool leaveOnly( const char *suiteName, const char *testName = 0 );
bool setUp();
bool tearDown();
static void reportError( const char *message );
};
void activateAllTests();
bool leaveOnly( const char *suiteName, const char *testName = 0 );
}
#endif // __cxxtest__RealDescriptions_h__
Descriptions.h
GlobalFixture.h
TestSuite.h
_TS_TRY
#define _TS_TRY
Definition TestSuite.h:209
_TSM_ASSERT_THROWS_NOTHING
#define _TSM_ASSERT_THROWS_NOTHING(f, l, m, e)
Definition TestSuite.h:465
_TSM_ASSERT
#define _TSM_ASSERT(f, l, m, e)
Definition TestSuite.h:242
_TS_CATCH_ABORT
#define _TS_CATCH_ABORT(b)
Definition TestSuite.h:216
i
int i
Definition cfEzgcd.cc:132
CxxTest::CommonDynamicSuiteDescription::_createLine
unsigned _createLine
Definition RealDescriptions.h:120
CxxTest::CommonDynamicSuiteDescription::CommonDynamicSuiteDescription
CommonDynamicSuiteDescription()
Definition RealDescriptions.cpp:185
CxxTest::CommonDynamicSuiteDescription::initialize
void initialize(const char *argFile, unsigned argLine, const char *argSuiteName, List &argTests, unsigned argCreateLine, unsigned argDestroyLine)
Definition RealDescriptions.cpp:194
CxxTest::CommonDynamicSuiteDescription::doInitialize
void doInitialize(unsigned argCreateLine, unsigned argDestroyLine)
Definition RealDescriptions.cpp:202
CxxTest::CommonDynamicSuiteDescription::_destroyLine
unsigned _destroyLine
Definition RealDescriptions.h:120
CxxTest::DynamicSuiteDescription::setUp
bool setUp()
Definition RealDescriptions.h:176
CxxTest::DynamicSuiteDescription::initialize
void initialize(const char *argFile, unsigned argLine, const char *argSuiteName, List &argTests, S *&argSuite, unsigned argCreateLine, unsigned argDestroyLine)
Definition RealDescriptions.h:140
CxxTest::DynamicSuiteDescription::_suite
S ** _suite
Definition RealDescriptions.h:172
CxxTest::DynamicSuiteDescription::suite
TestSuite * suite() const
Definition RealDescriptions.h:151
CxxTest::DynamicSuiteDescription::tearDown
bool tearDown()
Definition RealDescriptions.h:188
CxxTest::DynamicSuiteDescription::destroySuite
void destroySuite()
Definition RealDescriptions.h:165
CxxTest::DynamicSuiteDescription::createSuite
void createSuite()
Definition RealDescriptions.h:160
CxxTest::DynamicSuiteDescription::DynamicSuiteDescription
DynamicSuiteDescription()
Definition RealDescriptions.h:130
CxxTest::DynamicSuiteDescription::DynamicSuiteDescription
DynamicSuiteDescription(const char *argFile, unsigned argLine, const char *argSuiteName, List &argTests, S *&argSuite, unsigned argCreateLine, unsigned argDestroyLine)
Definition RealDescriptions.h:131
CxxTest::DynamicSuiteDescription::setSuite
void setSuite(S *s)
Definition RealDescriptions.h:158
CxxTest::DynamicSuiteDescription::realSuite
S * realSuite() const
Definition RealDescriptions.h:157
CxxTest::RealSuiteDescription::suiteName
const char * suiteName() const
Definition RealDescriptions.cpp:125
CxxTest::RealSuiteDescription::leaveOnly
bool leaveOnly(const char *testName)
Definition RealDescriptions.cpp:144
CxxTest::RealSuiteDescription::_line
unsigned _line
Definition RealDescriptions.h:74
CxxTest::RealSuiteDescription::testDescription
const TestDescription & testDescription(unsigned i) const
Definition RealDescriptions.cpp:134
CxxTest::RealSuiteDescription::line
unsigned line() const
Definition RealDescriptions.cpp:124
CxxTest::RealSuiteDescription::operator=
RealSuiteDescription & operator=(const RealSuiteDescription &)
CxxTest::RealSuiteDescription::firstTest
TestDescription * firstTest()
Definition RealDescriptions.cpp:127
CxxTest::RealSuiteDescription::next
SuiteDescription * next()
Definition RealDescriptions.cpp:129
CxxTest::RealSuiteDescription::_file
const char * _file
Definition RealDescriptions.h:73
CxxTest::RealSuiteDescription::numTests
unsigned numTests() const
Definition RealDescriptions.cpp:132
CxxTest::RealSuiteDescription::RealSuiteDescription
RealSuiteDescription()
Definition RealDescriptions.cpp:101
CxxTest::RealSuiteDescription::RealWorldDescription
friend class RealWorldDescription
Definition RealDescriptions.h:79
CxxTest::RealSuiteDescription::_suites
STATIC_INST_VAR List _suites
Definition RealDescriptions.h:78
CxxTest::RealSuiteDescription::RealSuiteDescription
RealSuiteDescription(const RealSuiteDescription &)
CxxTest::RealSuiteDescription::activateAllTests
void activateAllTests()
Definition RealDescriptions.cpp:139
CxxTest::RealSuiteDescription::_tests
List * _tests
Definition RealDescriptions.h:76
CxxTest::RealSuiteDescription::_suiteName
const char * _suiteName
Definition RealDescriptions.h:75
CxxTest::RealSuiteDescription::file
const char * file() const
Definition RealDescriptions.cpp:123
CxxTest::RealTestDescription::RealTestDescription
RealTestDescription(const RealTestDescription &)
CxxTest::RealTestDescription::_line
unsigned _line
Definition RealDescriptions.h:42
CxxTest::RealTestDescription::file
const char * file() const
Definition RealDescriptions.cpp:84
CxxTest::RealTestDescription::runTest
virtual void runTest()=0
CxxTest::RealTestDescription::_suite
SuiteDescription * _suite
Definition RealDescriptions.h:41
CxxTest::RealTestDescription::tearDown
bool tearDown()
Definition RealDescriptions.cpp:60
CxxTest::RealTestDescription::suiteName
const char * suiteName() const
Definition RealDescriptions.cpp:87
CxxTest::RealTestDescription::suite
TestSuite * suite() const
Definition RealDescriptions.cpp:92
CxxTest::RealTestDescription::RealTestDescription
RealTestDescription()
Definition RealDescriptions.cpp:13
CxxTest::RealTestDescription::testName
const char * testName() const
Definition RealDescriptions.cpp:86
CxxTest::RealTestDescription::next
TestDescription * next()
Definition RealDescriptions.cpp:89
CxxTest::RealTestDescription::line
unsigned line() const
Definition RealDescriptions.cpp:85
CxxTest::RealTestDescription::run
void run()
Definition RealDescriptions.cpp:94
CxxTest::RealTestDescription::setUp
bool setUp()
Definition RealDescriptions.cpp:36
CxxTest::RealTestDescription::_testName
const char * _testName
Definition RealDescriptions.h:43
CxxTest::RealTestDescription::operator=
RealTestDescription & operator=(const RealTestDescription &)
CxxTest::RealWorldDescription
Definition RealDescriptions.h:202
CxxTest::RealWorldDescription::setUp
bool setUp()
Definition RealDescriptions.cpp:262
CxxTest::RealWorldDescription::activateAllTests
void activateAllTests()
Definition RealDescriptions.cpp:241
CxxTest::RealWorldDescription::leaveOnly
bool leaveOnly(const char *suiteName, const char *testName=0)
Definition RealDescriptions.cpp:248
CxxTest::RealWorldDescription::suites
static List & suites()
Definition RealDescriptions.cpp:208
CxxTest::RealWorldDescription::firstSuite
SuiteDescription * firstSuite()
Definition RealDescriptions.cpp:226
CxxTest::RealWorldDescription::suiteDescription
const SuiteDescription & suiteDescription(unsigned i) const
Definition RealDescriptions.cpp:236
CxxTest::RealWorldDescription::tearDown
bool tearDown()
Definition RealDescriptions.cpp:278
CxxTest::RealWorldDescription::reportError
static void reportError(const char *message)
Definition RealDescriptions.cpp:294
CxxTest::RealWorldDescription::numTotalTests
unsigned numTotalTests(void) const
Definition RealDescriptions.cpp:218
CxxTest::RealWorldDescription::numSuites
unsigned numSuites(void) const
Definition RealDescriptions.cpp:213
CxxTest::StaticSuiteDescription::StaticSuiteDescription
StaticSuiteDescription(const StaticSuiteDescription &)
CxxTest::StaticSuiteDescription::operator=
StaticSuiteDescription & operator=(const StaticSuiteDescription &)
CxxTest::StaticSuiteDescription::_suite
TestSuite * _suite
Definition RealDescriptions.h:104
CxxTest::StaticSuiteDescription::suite
TestSuite * suite() const
Definition RealDescriptions.cpp:177
CxxTest::StaticSuiteDescription::tearDown
bool tearDown()
Definition RealDescriptions.cpp:183
CxxTest::StaticSuiteDescription::doInitialize
void doInitialize(TestSuite &argSuite)
Definition RealDescriptions.cpp:172
CxxTest::StaticSuiteDescription::setUp
bool setUp()
Definition RealDescriptions.cpp:182
CxxTest::StaticSuiteDescription::StaticSuiteDescription
StaticSuiteDescription()
Definition RealDescriptions.cpp:155
CxxTest::SuiteDescription
Definition Descriptions.h:32
CxxTest::TestDescription
Definition Descriptions.h:16
CxxTest::TestSuite
Definition TestSuite.h:22
CxxTest::WorldDescription
Definition Descriptions.h:54
STATIC_INST_VAR
#define STATIC_INST_VAR
Definition globaldefs.h:10
message
void message(int i, int *olddeg, int *reduc, kStrategy strat, int red_result)
Definition kutil.cc:7463
CxxTest
Definition Descriptions.cpp:7
CxxTest::activateAllTests
void activateAllTests()
Definition RealDescriptions.cpp:299
CxxTest::leaveOnly
bool leaveOnly(const char *suiteName, const char *testName)
Definition RealDescriptions.cpp:304
CxxTest::s
char * s
Definition ValueTraits.h:143
CxxTest::initialize
void initialize()
CxxTest::List
Definition LinkedList.h:12