FreeNOS
Data Structures | Macros | Typedefs | Functions
libtest

Generic test framework with support for assertions, automatic test discovery and test reporting. More...

Data Structures

class  DirectoryScanner
 Scan directory for automated tests. More...
 
class  ExternalTest
 Represents external test program. More...
 
class  LocalTest
 Represents test inside the same process. More...
 
class  StdoutReporter
 Output TestResults to standard output. More...
 
class  TAPReporter
 Output TestResults in TAP format to stdout. More...
 
class  TestChar< T >
 Generate test data for character strings. More...
 
class  TestData< T >
 Generate test data for a certain data type. More...
 
class  TestInstance
 Represents a test instance. More...
 
class  TestInt< T >
 Generate test data for integers. More...
 
class  TestReporter
 Responsible for outputting test results. More...
 
class  TestResult
 Represents a Test result created by a TestInstance. More...
 
class  TestRunner
 Reponsible for discovering and running tests. More...
 
class  TestSuite
 Maintains a list of test instances. More...
 
class  XMLReporter
 Output TestResults to standard output in XML format. More...
 

Macros

#define private   public
 Redefine private as public for accessing class members in testcases. More...
 
#define protected   public
 
#define TestCase(name)
 
#define testAssert(expression)
 Test if the given expression is true and return NOK otherwise. More...
 
#define testString(s1, s2)   testAssert(MemoryBlock::compare((s1), (s2)))
 Test if the given character strings are equal. More...
 

Typedefs

typedef TestResult TestFunction(void)
 

Functions

int main (int argc, char **argv)
 Default test program main function. More...
 

TestResult macros

#define OK   TestResult( TestResult::Success )
 
#define FAIL   TestResult( TestResult::Failure )
 
#define SKIP   TestResult( TestResult::Skipped )
 

Detailed Description

Generic test framework with support for assertions, automatic test discovery and test reporting.

Macro Definition Documentation

◆ FAIL

#define FAIL   TestResult( TestResult::Failure )

Definition at line 37 of file TestResult.h.

◆ OK

#define OK   TestResult( TestResult::Success )

Definition at line 36 of file TestResult.h.

◆ private

#define private   public

Redefine private as public for accessing class members in testcases.

Testcases sometimes need to access private members of a class. This define makes sure that a TestCase can access the private members.

Definition at line 38 of file TestCase.h.

◆ protected

#define protected   public

Definition at line 43 of file TestCase.h.

◆ SKIP

#define SKIP   TestResult( TestResult::Skipped )

Definition at line 38 of file TestResult.h.

◆ testAssert

#define testAssert (   expression)
Value:
if(!(expression)) \
{ \
char msg[256]; \
snprintf(msg, sizeof(msg), "%s:%d:%s testAssert failed: `%s' .. ", __FILE__, __LINE__, __FUNCTION__, QUOTE(expression)); \
}

Test if the given expression is true and return NOK otherwise.

Parameters
expressionThe expression to test against
Returns
NOK only if the expression evaluates to false

Definition at line 64 of file TestCase.h.

◆ TestCase

#define TestCase (   name)
Value:
TestResult name (void); \
LocalTest instance_##name (QUOTE(name), name); \
TestResult name (void)

Definition at line 52 of file TestCase.h.

◆ testString

#define testString (   s1,
  s2 
)    testAssert(MemoryBlock::compare((s1), (s2)))

Test if the given character strings are equal.

Definition at line 75 of file TestCase.h.

Typedef Documentation

◆ TestFunction

typedef TestResult TestFunction(void)

Definition at line 31 of file LocalTest.h.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Default test program main function.

Program entry point.

Parameters
argcArgument count
argvArgument values
Returns
Zero on success or number of failed tests on failure

Definition at line 41 of file TestMain.h.

References TestRunner::run().

TestResult::Failure
@ Failure
Definition: TestResult.h:57
QUOTE
#define QUOTE(x)
Stringfies the given input.
Definition: Macros.h:46
TestResult
Represents a Test result created by a TestInstance.
Definition: TestResult.h:47