CUnit Programmers Reference  3.0
Macros | Enumerations | Functions | Variables
Console

Macros

#define console_run_tests()   CU_console_run_tests()
 Deprecated (version 1). More...
 
#define IGNORE_RETURN(x)   if(x){}
 Ignore return values in modern gcc.
 

Enumerations

enum  CU_STATUS { CU_STATUS_CONTINUE = 1 , CU_STATUS_MOVE_UP , CU_STATUS_STOP }
 Console interface status flag. More...
 

Functions

CU_EXPORT void CU_console_run_tests (void)
 Run registered CUnit tests using the console interface.
 
static void console_registry_level_run (CU_pTestRegistry pRegistry)
 Main loop for console interface. More...
 
static CU_STATUS console_suite_level_run (CU_pSuite pSuite)
 Runs a selected suite within the console interface. More...
 
static CU_STATUS console_set_options_run (void)
 Sets CUnit options interactively using console interface. More...
 
static CU_ErrorCode console_run_all_tests (CU_pTestRegistry pRegistry)
 Runs all tests within the console interface. More...
 
static CU_ErrorCode console_run_suite (CU_pSuite pSuite)
 Runs a specified suite within the console interface. More...
 
static CU_ErrorCode console_run_single_test (CU_pSuite pSuite, CU_pTest pTest)
 ( Runs a specific test for the specified suite within the console interface. More...
 
static void console_test_start_message_handler (const CU_pTest pTest, const CU_pSuite pSuite)
 Handler function called at start of each test. More...
 
static void console_test_complete_message_handler (const CU_pTest pTest, const CU_pSuite pSuite, const CU_pFailureRecord pFailure)
 Handler function called at completion of each test. More...
 
static void console_all_tests_complete_message_handler (const CU_pFailureRecord pFailure)
 Handler function called at completion of all tests in a suite. More...
 
static void console_suite_init_failure_message_handler (const CU_pSuite pSuite)
 Handler function called when suite initialization fails. More...
 
static void console_suite_cleanup_failure_message_handler (const CU_pSuite pSuite)
 Handler function called when suite cleanup fails. More...
 
static CU_ErrorCode select_test (CU_pSuite pSuite, CU_pTest *ppTest)
 Reads the number of a test from standard input and locates the test at that position. More...
 
static CU_ErrorCode select_suite (CU_pTestRegistry pRegistry, CU_pSuite *ppSuite)
 Reads the number of a suite from standard input and locates the suite at that position. More...
 
static void list_suites (CU_pTestRegistry pRegistry)
 Lists the suites in a registry to standard output. More...
 
static void list_tests (CU_pSuite pSuite)
 Lists the tests in a suite to standard output. More...
 
static void show_failures (void)
 Displays the record of test failures on standard output.
 

Variables

static CU_pSuite f_pRunningSuite = NULL
 Pointer to the currently running suite.
 
static size_t f_yes_width = 0
 Common width measurements for output formatting.
 

Detailed Description

Macro Definition Documentation

◆ console_run_tests

#define console_run_tests ( )    CU_console_run_tests()

Deprecated (version 1).

Deprecated:
Use CU_console_run_tests().

Enumeration Type Documentation

◆ CU_STATUS

enum CU_STATUS

Console interface status flag.

Enumerator
CU_STATUS_CONTINUE 

Continue processing commands in current menu.

CU_STATUS_MOVE_UP 

Move up to the previous menu.

CU_STATUS_STOP 

Stop processing (user selected 'Quit').

Function Documentation

◆ console_all_tests_complete_message_handler()

static void console_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().

◆ console_registry_level_run()

static void console_registry_level_run ( CU_pTestRegistry  pRegistry)
static

Main loop for console interface.

Displays actions and responds based on user imput. If pRegistry is NULL, will use the default internal CUnit test registry.

Parameters
pRegistryThe CU_pTestRegistry to use for testing.

References CU_STATUS_CONTINUE.

◆ console_run_all_tests()

static CU_ErrorCode console_run_all_tests ( CU_pTestRegistry  pRegistry)
static

Runs all tests within the console interface.

The test registry is changed to the specified registry before running the tests, and reset to the original registry when done. If pRegistry is NULL, the default internal CUnit test registry is used.

Parameters
pRegistryThe CU_pTestRegistry containing the tests to be run.
Returns
An error code indicating the error status during the test run.

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

◆ console_run_single_test()

static CU_ErrorCode console_run_single_test ( CU_pSuite  pSuite,
CU_pTest  pTest 
)
static

( Runs a specific 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.

◆ console_run_suite()

static CU_ErrorCode console_run_suite ( CU_pSuite  pSuite)
static

Runs a specified suite within the console 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.

◆ console_set_options_run()

static CU_STATUS console_set_options_run ( void  )
static

Sets CUnit options interactively using console interface.

Displays actions and responds based on user imput.

References CU_STATUS_CONTINUE.

◆ console_suite_cleanup_failure_message_handler()

static void console_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_Suite::pName.

◆ console_suite_init_failure_message_handler()

static void console_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_Suite::pName.

◆ console_suite_level_run()

static CU_STATUS console_suite_level_run ( CU_pSuite  pSuite)
static

Runs a selected suite within the console interface.

Displays actions and responds based on user imput.

Parameters
pSuiteThe suite to use for testing (non-NULL).

References CU_STATUS_CONTINUE, and CU_Suite::pName.

◆ console_test_complete_message_handler()

static void console_test_complete_message_handler ( const CU_pTest  pTest,
const CU_pSuite  pSuite,
const CU_pFailureRecord  pFailure 
)
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.

◆ console_test_start_message_handler()

static void console_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 f_pRunningSuite, CU_Test::pName, and CU_Suite::pName.

◆ list_suites()

static void list_suites ( CU_pTestRegistry  pRegistry)
static

Lists the suites in a registry to standard output.

Parameters
pRegistryThe CU_pTestRegistry to query (non-NULL).

References CU_get_registry(), and CU_TestRegistry::uiNumberOfSuites.

◆ list_tests()

static void list_tests ( CU_pSuite  pSuite)
static

Lists the tests in a suite to standard output.

Parameters
pSuiteThe suite to query (non-NULL).

References CU_Suite::pName, and CU_Suite::uiNumberOfTests.

◆ select_suite()

static CU_ErrorCode select_suite ( CU_pTestRegistry  pRegistry,
CU_pSuite ppSuite 
)
static

Reads the number of a suite from standard input and locates the suite at that position.

If pRegistry is NULL, the default CUnit registry will be used. The located pSuite is returned in ppSuite. ppSuite will be NULL if there is no suite in the registry having the input name. Returns NULL if the suite is successfully located, non-NULL otherwise.

Parameters
pRegistryThe CU_pTestRegistry to query. If NULL, use the default internal CUnit test registry.
ppSuitePointer to location to store the selected suite.
Returns
CUE_SUCCESS if a suite was successfully selected, CUE_NOSUITE otherwise. On return, ppSuite points to the suite selected.

References CU_get_registry(), and CU_TestRegistry::uiNumberOfSuites.

◆ select_test()

static CU_ErrorCode select_test ( CU_pSuite  pSuite,
CU_pTest ppTest 
)
static

Reads the number of a test from standard input and locates the test at that position.

A pointer to the located test is stored in ppTest upon return.

Parameters
pSuiteThe suite to be queried.
ppTestPointer to location to store the selected test.
Returns
CUE_SUCCESS if a test was successfully selected, CUE_NOTEST otherwise. On return, ppTest points to the test selected, or NULL if none.

References CU_Suite::pName, and CU_Suite::uiNumberOfTests.