Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
TestCase Class Reference

#include <elm/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 , class U >
void check_equal (CString file, int line, CString text, const T &result, const U &reference)
 
void prepare (void)
 
void complete (void)
 
void perform (void)
 
bool isSuccessful (void) const
 
bool hasFailed (void) const
 
bool isFullPath () const
 
void setFullPath (bool x)
 

Protected Member Functions

virtual void execute (void)
 

Protected Attributes

TestCase__case
 
bool full_path
 

Detailed Description

This class is used for implementing macro for unit tests.

@seealso TestSet, CHECK, TEST_BEGIN, CHECK_BEGIN

Constructor & Destructor Documentation

◆ TestCase()

TestCase ( CString  name)

Build a new tes case.

Parameters
nameName of the test case.

References TestSet::def.

◆ ~TestCase()

~TestCase ( void  )
virtual

Member Function Documentation

◆ check()

void 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 TestCase::failed(), TestCase::succeeded(), and TestCase::test().

Referenced by TestCase::check_equal(), and TestCase::require().

◆ check_equal()

void check_equal ( CString  file,
int  line,
CString  text,
const T &  result,
const U &  reference 
)
inline

◆ complete()

void complete ( void  )

Final display of the test case.

References elm::cout, elm::io::endl, and elm::io::PLAIN.

Referenced by TestCase::perform().

◆ execute()

void execute ( void  )
protectedvirtual

Actual actions of the test.

Referenced by TestCase::perform().

◆ failed()

void failed ( void  )

Inform that the current test has failed.

References elm::cout, and elm::io::endl.

Referenced by TestCase::check().

◆ hasFailed()

bool hasFailed ( void  ) const
inline

◆ initialize()

void initialize ( void  )

For internal work only. Don't call it.

References TestSet::def.

◆ isFullPath()

bool isFullPath ( ) const
inline

Test if the source paths are fully displayed. Otherwise, only the name of the source is display.

Returns
True if the full path option is enabled, false else.

References TestCase::full_path.

◆ isSuccessful()

bool isSuccessful ( void  ) const
inline

◆ name()

cstring name ( void  )
inline

Referenced by TestCase::prepare().

◆ perform()

void perform ( void  )

Execute the test case.

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

◆ prepare()

void prepare ( void  )

Perform the display before the test execution.

References elm::cout, elm::io::endl, and TestCase::name().

Referenced by TestCase::perform().

◆ require()

bool 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 TestCase::check(), elm::cout, elm::io::endl, and elm::io::PLAIN.

◆ setFullPath()

void setFullPath ( bool  x)
inline

Set the full source option.

Parameters
xTrue to enable full path display.

References TestCase::full_path.

◆ succeeded()

void succeeded ( void  )

Inform that the current test has succeeded.

References elm::cout, and elm::io::endl.

Referenced by TestCase::check().

◆ test()

void test ( CString  file,
int  line,
CString  text 
)

Prepare to do a test.

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

References elm::cout, TestCase::full_path, and Path::namePart().

Referenced by TestCase::check(), and TestCase::check_equal().

Member Data Documentation

◆ __case

TestCase& __case
protected

◆ full_path

bool full_path
protected

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