Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
elm::TestCase Class Reference

#include <elm/util/test.h>

Public Member Functions

 TestCase (CString name)
 
void initialize (void)
 
virtual ~TestCase (void)
 
cstring name (void)
 
void test (CString file, int line, CString text)
 
void failed (void)
 
void succeeded (void)
 
void check (CString file, int line, CString text, bool result)
 
bool require (CString file, int line, CString text, bool result)
 
template<class T >
void check_equal (CString file, int line, CString text, const T &result, const T &reference)
 
void prepare (void)
 
void complete (void)
 
void perform (void)
 
bool hasFailed (void) const
 

Protected Member Functions

virtual void execute (void)
 

Protected Attributes

TestCase__case
 

Detailed Description

This class is used for implementing macro for unit tests.

TestSet, CHECK, TEST_BEGIN, CHECK_BEGIN

Constructor & Destructor Documentation

elm::TestCase::TestCase ( CString  name)

Build a new tes case.

Parameters
nameName of the test case.

References elm::TestSet::def, and elm::Initializer< T >::record().

elm::TestCase::~TestCase ( void  )
virtual

Member Function Documentation

void elm::TestCase::check ( CString  file,
int  line,
CString  text,
bool  result 
)

Check if a test has returned true.

Parameters
fileSource file containing the test.
lineLine in the source file of the test.
textExplanation about the test.
resultResult of the test.

References failed(), succeeded(), and test().

Referenced by check_equal(), and require().

template<class T >
void elm::TestCase::check_equal ( CString  file,
int  line,
CString  text,
const T &  result,
const T &  reference 
)

References check(), and elm::cout.

void elm::TestCase::complete ( void  )

Final display of the test case.

References elm::cout.

Referenced by perform().

void elm::TestCase::execute ( void  )
protectedvirtual

Actual actions of the test.

Referenced by perform().

void elm::TestCase::failed ( void  )

Inform that the current test has failed.

References elm::cout.

Referenced by check().

bool elm::TestCase::hasFailed ( void  ) const
void elm::TestCase::initialize ( void  )

For internal work only. Don't call it.

References elm::TestSet::def.

cstring elm::TestCase::name ( void  )

Referenced by prepare().

void elm::TestCase::perform ( void  )

Execute the test case.

References complete(), execute(), and prepare().

void elm::TestCase::prepare ( void  )

Perform the display before the test execution.

References elm::cout, and name().

Referenced by perform().

bool elm::TestCase::require ( CString  file,
int  line,
CString  text,
bool  result 
)

Same as check but also returns value and specific message for ending the test due to main failure.

Parameters
fileFile containing the test source.
lineLine where the test is implemented.
textText describing the test.
resultResult of the test.
Returns
Result of the test.

References check(), and elm::cout.

void elm::TestCase::succeeded ( void  )

Inform that the current test has succeeded.

References elm::cout.

Referenced by check().

void elm::TestCase::test ( CString  file,
int  line,
CString  text 
)

Prepare to do a test.

Parameters
fileSource file.
lineSource line.
textCode text to test.

References elm::cout.

Referenced by check().

Member Data Documentation

TestCase& elm::TestCase::__case
protected

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