HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_TestUnit Class Reference

Status maintainer used to run a test. More...

#include <UT_TestManager.h>

Public Member Functions

 UT_TestUnit (const char *format,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
 
 ~UT_TestUnit ()
 
bool fail (const char *format=NULL,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
 
bool bool ok (const char *format=NULL,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
 
bool bool void restartTimer (const char *format=NULL,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
 
bool bool void void setAlwaysPrint (bool f)
 Enable printing of success/failure when this unit test is destroyed. More...
 
bool getStatus () const
 Query the status of the test. More...
 
bool setStatus (bool b)
 

Detailed Description

Status maintainer used to run a test.

This class simplifies the book-keeping when running a test. The unit test will automatically log information (i.e. performance, memory) if the UT_TestManager is so configured.

Example:

static bool
unitTest(int argument)
{
UT_TestUnit status("UnitTest: %d", argument);
if (!doTest(...))
return status.fail("Test failed: %s", some_string);
return status.ok();
}

Definition at line 84 of file UT_TestManager.h.

Constructor & Destructor Documentation

UT_TestUnit::UT_TestUnit ( const char *  format,
  ... 
)
UT_TestUnit::~UT_TestUnit ( )

Member Function Documentation

bool UT_TestUnit::fail ( const char *  format = NULL,
  ... 
)

Print out the message given by a format. This includes the test name, and other information. No newline should be included in the format.

The function always returns false.

bool UT_TestUnit::getStatus ( ) const
inline

Query the status of the test.

Definition at line 114 of file UT_TestManager.h.

bool bool UT_TestUnit::ok ( const char *  format = NULL,
  ... 
)

Print out the message given by a format. This includes the test name, and other information. No newline should be included in the format.

The function always returns true.

bool bool void UT_TestUnit::restartTimer ( const char *  format = NULL,
  ... 
)

Restart the timer. If format is non-NULL, then it will print the time as well from when the timer last started. Note that the timer is automatically started in the constructor.

bool bool void void UT_TestUnit::setAlwaysPrint ( bool  f)
inline

Enable printing of success/failure when this unit test is destroyed.

Definition at line 111 of file UT_TestManager.h.

bool UT_TestUnit::setStatus ( bool  b)
inline

Definition at line 115 of file UT_TestManager.h.


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