CUnit Programmers Reference  3.0
Enumerations | Functions | Variables
Basic

Enumerations

enum  CU_BasicRunMode { CU_BRM_NORMAL = 0 , CU_BRM_SILENT , CU_BRM_VERBOSE }
 Run modes for the basic interface. More...
 

Functions

CU_EXPORT CU_ErrorCode CU_basic_run_tests (void)
 Runs all registered CUnit tests using the basic interface. More...
 
CU_EXPORT CU_ErrorCode CU_basic_run_suite (CU_pSuite pSuite)
 Runs all tests for a specific suite in the basic interface. More...
 
CU_EXPORT CU_ErrorCode CU_basic_run_test (CU_pSuite pSuite, CU_pTest pTest)
 Runs a single test in a specific suite in the basic interface. More...
 
CU_EXPORT void CU_basic_set_mode (CU_BasicRunMode mode)
 Sets the run mode for the basic interface. More...
 
CU_EXPORT CU_BasicRunMode CU_basic_get_mode (void)
 Retrieves the current run mode for the basic interface. More...
 
CU_EXPORT void CU_basic_show_failures (CU_pFailureRecord pFailure)
 Prints a summary of run failures to stdout. More...
 
CU_EXPORT void CCU_basic_add_handlers (void)
 Append the basic (stdout) test event handlers.
 
static CU_ErrorCode basic_initialize (void)
 Performs inialization actions for the basic interface. More...
 
static CU_ErrorCode basic_run_all_tests (CU_pTestRegistry pRegistry)
 Runs all tests within the basic interface. More...
 
static CU_ErrorCode basic_run_suite (CU_pSuite pSuite)
 Runs a specified suite within the basic interface. More...
 
static CU_ErrorCode basic_run_single_test (CU_pSuite pSuite, CU_pTest pTest)
 Runs a single test for the specified suite within the console interface. More...
 
static void basic_test_start_message_handler (const CU_pTest pTest, const CU_pSuite pSuite)
 Handler function called at start of each test. More...
 
static void basic_test_complete_message_handler (const CU_pTest pTest, const CU_pSuite pSuite, const CU_pFailureRecord pFailureList)
 Handler function called at completion of each test. More...
 
static void basic_all_tests_complete_message_handler (const CU_pFailureRecord pFailure)
 Handler function called at completion of all tests in a suite. More...
 
static void basic_suite_init_failure_message_handler (const CU_pSuite pSuite)
 Handler function called when suite initialization fails. More...
 
static void basic_suite_cleanup_failure_message_handler (const CU_pSuite pSuite)
 Handler function called when suite cleanup fails. More...
 

Variables

static CU_pSuite f_pRunningSuite = NULL
 Pointer to the currently running suite.
 
static CU_BasicRunMode f_run_mode = CU_BRM_NORMAL
 Current run mode.
 

Detailed Description

Enumeration Type Documentation

◆ CU_BasicRunMode

Run modes for the basic interface.

Enumerator
CU_BRM_NORMAL 

Normal mode - failures and run summary are printed [default].

CU_BRM_SILENT 

Silent mode - no output is printed except framework error messages.

CU_BRM_VERBOSE 

Verbose mode - maximum output of run details.

Function Documentation

◆ basic_all_tests_complete_message_handler()

static void basic_all_tests_complete_message_handler ( const CU_pFailureRecord  pFailure)
static

Handler function called at completion of all tests in a suite.

Parameters
pFailurePointer to the test failure record list.

References CU_print_run_results().

Referenced by CCU_basic_add_handlers().

◆ basic_initialize()

static CU_ErrorCode basic_initialize ( void  )
static

Performs inialization actions for the basic interface.

This includes setting output to unbuffered, printing a welcome message, and setting the test run handlers.

Returns
An error code indicating the framework error condition.

References CU_BRM_SILENT, CU_set_error(), CUE_SUCCESS, and f_run_mode.

Referenced by CU_basic_run_suite(), and CU_basic_run_test().

◆ basic_run_all_tests()

static CU_ErrorCode basic_run_all_tests ( CU_pTestRegistry  pRegistry)
static

Runs all tests within the basic interface.

If non-NULL, the test registry is changed to the specified registry before running the tests, and reset to the original registry when done. If NULL, the default CUnit test registry will be used.

Parameters
pRegistryThe CU_pTestRegistry containing the tests to be run. If NULL, use the default registry.
Returns
An error code indicating the error status during the test run.

References CU_run_all_tests(), CU_set_registry(), and f_pRunningSuite.

◆ basic_run_single_test()

static CU_ErrorCode basic_run_single_test ( CU_pSuite  pSuite,
CU_pTest  pTest 
)
static

Runs a single test for the specified suite within the console interface.

Parameters
pSuiteThe suite containing the test to be run (non-NULL).
pTestThe test to be run (non-NULL).
Returns
An error code indicating the error status during the test run.

References CU_run_test(), and f_pRunningSuite.

Referenced by CU_basic_run_test().

◆ basic_run_suite()

static CU_ErrorCode basic_run_suite ( CU_pSuite  pSuite)
static

Runs a specified suite within the basic interface.

Parameters
pSuiteThe suite to be run (non-NULL).
Returns
An error code indicating the error status during the test run.

References CU_run_suite(), and f_pRunningSuite.

Referenced by CU_basic_run_suite().

◆ basic_suite_cleanup_failure_message_handler()

static void basic_suite_cleanup_failure_message_handler ( const CU_pSuite  pSuite)
static

Handler function called when suite cleanup fails.

Parameters
pSuiteThe suite for which cleanup failed.

References CU_BRM_SILENT, f_run_mode, and CU_Suite::pName.

Referenced by CCU_basic_add_handlers().

◆ basic_suite_init_failure_message_handler()

static void basic_suite_init_failure_message_handler ( const CU_pSuite  pSuite)
static

Handler function called when suite initialization fails.

Parameters
pSuiteThe suite for which initialization failed.

References CU_BRM_SILENT, f_run_mode, and CU_Suite::pName.

Referenced by CCU_basic_add_handlers().

◆ basic_test_complete_message_handler()

static void basic_test_complete_message_handler ( const CU_pTest  pTest,
const CU_pSuite  pSuite,
const CU_pFailureRecord  pFailureList 
)
static

Handler function called at completion of each test.

Parameters
pTestThe test being run.
pSuiteThe suite containing the test.
pFailurePointer to the 1st failure record for this test.

References CU_BRM_VERBOSE, and f_run_mode.

Referenced by CCU_basic_add_handlers().

◆ basic_test_start_message_handler()

static void basic_test_start_message_handler ( const CU_pTest  pTest,
const CU_pSuite  pSuite 
)
static

Handler function called at start of each test.

Parameters
pTestThe test being run.
pSuiteThe suite containing the test.

References CU_BRM_VERBOSE, f_pRunningSuite, f_run_mode, CU_Test::pName, and CU_Suite::pName.

Referenced by CCU_basic_add_handlers().

◆ CU_basic_get_mode()

CU_BasicRunMode CU_basic_get_mode ( void  )

Retrieves the current run mode for the basic interface.

Returns
The current CU_BasicRunMode setting for test runs using the basic interface.

References f_run_mode.

◆ CU_basic_run_suite()

CU_ErrorCode CU_basic_run_suite ( CU_pSuite  pSuite)

Runs all tests for a specific suite in the basic interface.

If pSuite is NULL, the function returns without taking any action. The default CU_BasicRunMode is used unless it has been changed using CU_basic_set_mode().

Parameters
pSuiteThe CU_Suite to run.
Returns
A CU_ErrorCode indicating the framework error condition, including CUE_NOSUITE - pSuite was NULL.

References basic_initialize(), basic_run_suite(), CUE_NOSUITE, and CUE_SUCCESS.

◆ CU_basic_run_test()

CU_ErrorCode CU_basic_run_test ( CU_pSuite  pSuite,
CU_pTest  pTest 
)

Runs a single test in a specific suite in the basic interface.

If pSuite or pTest is NULL, the function returns without taking any action. The default CU_BasicRunMode is used unless it has been changed using CU_basic_set_mode.

Parameters
pSuiteThe CU_Suite holding the CU_Test to run.
pTestThe CU_Test to run.
Returns
A CU_ErrorCode indicating the framework error condition, including CUE_NOSUITE - pSuite was NULL. CUE_NOTEST - pTest was NULL.

References basic_initialize(), basic_run_single_test(), CUE_NOSUITE, CUE_NOTEST, and CUE_SUCCESS.

◆ CU_basic_run_tests()

CU_ErrorCode CU_basic_run_tests ( void  )

Runs all registered CUnit tests using the basic interface.

The default CU_BasicRunMode is used unless it has been previously changed using CU_basic_set_mode(). The CUnit test registry must have been initialized before calling this function.

Returns
A CU_ErrorCode indicating the framework error condition, including CUE_NOREGISTRY - Registry has not been initialized.

References CU_BRM_SILENT, CU_get_registry(), and f_run_mode.

◆ CU_basic_set_mode()

void CU_basic_set_mode ( CU_BasicRunMode  mode)

Sets the run mode for the basic interface.

Parameters
modeThe new CU_BasicRunMode for subsequent test runs using the basic interface.

References f_run_mode.

◆ CU_basic_show_failures()

void CU_basic_show_failures ( CU_pFailureRecord  pFailure)

Prints a summary of run failures to stdout.

This is provided for user convenience upon request, and does not take into account the current run mode. The failures are printed to stdout independent of the most recent run mode.

Parameters
pFailureList of CU_pFailureRecord's to output.

References CU_FailureRecord::pNext, CU_FailureRecord::strCondition, CU_FailureRecord::strFileName, CU_FailureRecord::strFunction, and CU_FailureRecord::uiLineNumber.