CUnit Programmers Reference  3.0
Data Structures | Macros | Enumerations | Functions | Variables
Curses

Data Structures

struct  APPWINDOWS
 Pointers to curses interface windows. More...
 
struct  APPPAD
 Window elements. More...
 

Macros

#define curses_run_tests()   CU_curses_run_tests()
 Deprecated (version 1). More...
 
#define false   (0)
 Local boolean definition for false.
 
#define true   (~false)
 Local boolean definition for true.
 
#define STRING_LENGTH   128
 Standard string length.
 

Enumerations

enum  STATUS { CONTINUE = 1 , MOVE_UP , STOP }
 Curses interface status flag. More...
 
enum  MENU_TYPE
 Menu type.
 

Functions

CU_EXPORT void CU_curses_run_tests (void)
 Run registered CUnit tests using the curses interface.
 
static bool initialize_windows (void)
 Initialize the curses interface windows.
 
static void uninitialize_windows (void)
 Clean up and delete curses interface windows.
 
static void refresh_windows (void)
 Refresh curses interface windows. More...
 
static void refresh_title_window (void)
 Refresh the title window.
 
static void refresh_progress_window (void)
 Refresh the progress bar window.
 
static void refresh_summary_window (void)
 Refresh the summary window.
 
static void refresh_run_summary_window (void)
 Refresh the run summary window.
 
static void refresh_details_window (void)
 Refresh the details window.
 
static void refresh_options_window (void)
 Refresh the options window.
 
static void show_detail_window_message (const char *msg)
 Prints a custom message in the detail window.
 
static bool create_pad (APPPAD *pPad, WINDOW *pParent, unsigned int uiRows, unsigned int uiCols)
 Create a window having specified parent and dimensions. More...
 
static void scroll_window (int nCommand, APPPAD *pPad, void(*parent_refresh)(void))
 Scroll a window. More...
 
static bool test_initialize (void)
 Initialize the message handlers in preparation for running tests.
 
static void show_progress_bar (void)
 Show the progress bar window.
 
static const char * get_hotkey (const char *szStr, int *pPos)
 Parse a string and return the coded hotkeys. More...
 
static void read_input_string (const char szPrompt[], char szValue[], int nBytes)
 Display a prompt, then read a string from the keyboard. More...
 
static STATUS curses_registry_level_run (CU_pTestRegistry pRegistry)
 Main loop for curses interface. More...
 
static STATUS curses_suite_level_run (CU_pSuite pSuite)
 Run a selected suite within the curses interface. More...
 
static STATUS curses_set_options_run (void)
 Sets CUnit options interactively using curses interface. More...
 
static CU_ErrorCode curses_run_all_tests (CU_pTestRegistry pRegistry)
 Run all tests within the curses interface. More...
 
static CU_ErrorCode curses_run_suite_tests (CU_pSuite pSuite)
 Run a specified suite within the curses interface. More...
 
static CU_ErrorCode curses_run_single_test (CU_pSuite pSuite, CU_pTest pTest)
 Run a specific test for the specified suite within the curses interface. More...
 
static void curses_test_start_message_handler (const CU_pTest pTest, const CU_pSuite pSuite)
 Handler function called at start of each test. More...
 
static void curses_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 curses_all_tests_complete_message_handler (const CU_pFailureRecord pFailure)
 Handler function called at completion of all tests in a suite. More...
 
static void curses_suite_init_failure_message_handler (const CU_pSuite pSuite)
 Handler function called when suite initialization fails. More...
 
static void list_suites (CU_pTestRegistry pRegistry)
 Print a list of registered suites to the detail window. More...
 
static void list_tests (CU_pSuite pSuite)
 Print a list of tests contained in a specified suite to the detail window. More...
 
static void show_failures (void)
 Display the record of test failures in the detail window.
 
static void show_registry_level_help (void)
 Prints help text for registry level to detail window.
 
static void show_suite_level_help (CU_pSuite pSuite)
 Prints help text for suite level to detail window.
 
static void reset_run_parameters (void)
 Reset the local run counters and prepare for a test run.
 

Variables

static const char * MAIN_OPTIONS
 String holding main menu run options.
 
static const char * SUITE_OPTIONS
 String holding suite menu run options.
 
static const int CLEAR_COLOR = 1
 Clear color.
 
static const int TITLE_COLOR = 2
 Title color.
 
static const int PROGRESS_BACKGROUND_COLOR = 3
 progress bar background color.
 
static const int PROGRESS_SUCCESS_COLOR = 4
 Progress bar success color.
 
static const int PROGRESS_FAILURE_COLOR = 5
 Progress bar failure color.
 
static const int MENU_COLOR = 6
 Menu color.
 
static const char *const f_szProgress = N_("Progress ")
 Text for progress bar.
 
static const char * f_szOptions = NULL
 String containing options.
 
static CU_pTest f_pCurrentTest = NULL
 Pointer to the test currently being run.
 
static CU_pSuite f_pCurrentSuite = NULL
 Pointer to the suite currently being run.
 
static unsigned int f_uiTotalTests = 0
 Number of tests in registered suites.
 
static unsigned int f_uiTestsRun = 0
 Number of tests actually run.
 
static unsigned int f_uiTestsSkipped = 0
 Number of tests skipped during run.
 
static unsigned int f_uiTestsFailed = 0
 Number of tests having failed assertions.
 
static unsigned int f_uiTestsRunSuccessful = 0
 Number of tests run with no failed assertions.
 
static unsigned int f_uiTotalSuites = 0
 Number of registered suites.
 
static unsigned int f_uiSuitesSkipped = 0
 Number of suites skipped during run.
 
static short f_nLeft
 Left window position.
 
static short f_nTop
 Top window position.
 
static short f_nWidth
 Width of window.
 
static short f_nHeight
 Height of window.
 
static size_t f_yes_width = 0
 Common width measurements for output formatting.
 
static APPWINDOWS application_windows = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}
 Pointers to curses interface windows.
 
static APPPAD details_pad = {NULL, 0, 0, 0, 0, 0, 0, 0, 0}
 Details window definition.
 

Detailed Description

Macro Definition Documentation

◆ curses_run_tests

#define curses_run_tests ( )    CU_curses_run_tests()

Deprecated (version 1).

Deprecated:
Use CU_curses_run_tests().

Enumeration Type Documentation

◆ STATUS

enum STATUS

Curses interface status flag.

Enumerator
CONTINUE 

Continue processing commands in current menu.

MOVE_UP 

Move up to the previous menu.

STOP 

Stop processing (user selected 'Quit').

Function Documentation

◆ create_pad()

static bool create_pad ( APPPAD pPad,
WINDOW *  pParent,
unsigned int  uiRows,
unsigned int  uiCols 
)
static

Create a window having specified parent and dimensions.

Parameters
pPadPointer to the new window.
pParentParent window.
uiRowsNumber of rows for new window.
uiColsNumber of columnss for new window.

References application_windows, APPWINDOWS::pDetailsWin, APPPAD::pPad, APPPAD::uiColumns, APPPAD::uiPadCol, APPPAD::uiPadRow, APPPAD::uiRows, APPPAD::uiWinColumns, APPPAD::uiWinLeft, APPPAD::uiWinRows, and APPPAD::uiWinTop.

Referenced by curses_all_tests_complete_message_handler(), curses_set_options_run(), list_tests(), show_detail_window_message(), show_registry_level_help(), and show_suite_level_help().

◆ curses_all_tests_complete_message_handler()

static void curses_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 application_windows, create_pad(), details_pad, f_pCurrentSuite, f_pCurrentTest, APPWINDOWS::pDetailsWin, and APPPAD::pPad.

Referenced by test_initialize().

◆ curses_registry_level_run()

static STATUS curses_registry_level_run ( CU_pTestRegistry  pRegistry)
static

Main loop for curses interface.

Displays actions and responds based on user imput.

Parameters
pRegistryThe CU_pTestRegistry to use for testing. If NULL, uses the default registry.

References CU_get_registry(), and STRING_LENGTH.

◆ curses_run_all_tests()

static CU_ErrorCode curses_run_all_tests ( CU_pTestRegistry  pRegistry)
static

Run all tests within the curses interface.

The test registry is changed to the specified registry before running the tests, and reset to the original registry when done.

Parameters
pRegistryThe CU_pTestRegistry containing the tests to be run (non-NULL).
Returns
An error code indicating the error status during the test run.

References CU_run_all_tests(), CU_set_registry(), f_uiTotalSuites, f_uiTotalTests, reset_run_parameters(), CU_TestRegistry::uiNumberOfSuites, and CU_TestRegistry::uiNumberOfTests.

◆ curses_run_single_test()

static CU_ErrorCode curses_run_single_test ( CU_pSuite  pSuite,
CU_pTest  pTest 
)
static

Run a specific test for the specified suite within the curses 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(), f_uiTotalSuites, f_uiTotalTests, and reset_run_parameters().

◆ curses_run_suite_tests()

static CU_ErrorCode curses_run_suite_tests ( CU_pSuite  pSuite)
static

Run a specified suite within the curses 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(), f_uiTotalSuites, f_uiTotalTests, reset_run_parameters(), and CU_Suite::uiNumberOfTests.

◆ curses_set_options_run()

static STATUS curses_set_options_run ( void  )
static

Sets CUnit options interactively using curses interface.

Displays actions and responds based on user imput.

References application_windows, CONTINUE, create_pad(), details_pad, APPWINDOWS::pDetailsWin, APPPAD::pPad, and STRING_LENGTH.

◆ curses_suite_init_failure_message_handler()

static void curses_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 f_uiSuitesSkipped, f_uiTestsSkipped, refresh_progress_window(), refresh_summary_window(), and CU_Suite::uiNumberOfTests.

Referenced by test_initialize().

◆ curses_suite_level_run()

static STATUS curses_suite_level_run ( CU_pSuite  pSuite)
static

Run a selected suite within the curses interface.

Displays actions and responds based on user imput.

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

References CU_get_registry(), f_szOptions, CU_Suite::pName, and STRING_LENGTH.

◆ curses_test_complete_message_handler()

static void curses_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.

References CU_get_number_of_tests_failed(), f_uiTestsFailed, f_uiTestsRun, f_uiTestsRunSuccessful, refresh_progress_window(), and refresh_summary_window().

Referenced by test_initialize().

◆ curses_test_start_message_handler()

static void curses_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_pCurrentSuite, f_pCurrentTest, and refresh_run_summary_window().

Referenced by test_initialize().

◆ get_hotkey()

static const char * get_hotkey ( const char *  szStr,
int *  pPos 
)
static

Parse a string and return the coded hotkeys.

If called with szStr non-NULL, the string is simply stored. Subsequent calls with szStr NULL will cause the hotkeys in the string (chars between parentheses) to be returned sequentially in the order in which they appear in the original string.

Parameters
szStrString to parse (non-NULL to set, NULL to parse).
pPosUsed to store position of the next '('.
Returns
If szStr is non-NULL, it is returned. If szStr is NULL, the next hotkey character is returned, or NULL if there are no more hotkey characters in the original string.

Referenced by refresh_options_window().

◆ list_suites()

static void list_suites ( CU_pTestRegistry  pRegistry)
static

Print a list of registered suites to the detail window.

Parameters
pRegistryThe CU_pTestRegistry to query (non-NULL).

References CU_get_registry(), show_detail_window_message(), STRING_LENGTH, and CU_TestRegistry::uiNumberOfSuites.

◆ list_tests()

static void list_tests ( CU_pSuite  pSuite)
static

Print a list of tests contained in a specified suite to the detail window.

Parameters
pSuiteThe suite to query (non-NULL).

References application_windows, create_pad(), details_pad, APPWINDOWS::pDetailsWin, CU_Suite::pName, STRING_LENGTH, and CU_Suite::uiNumberOfTests.

◆ read_input_string()

static void read_input_string ( const char  szPrompt[],
char  szValue[],
int  nBytes 
)
static

Display a prompt, then read a string from the keyboard.

Parameters
szPromptThe prompt to display.
szValueThe string in which to store the response.
nBytesThe length of the szValue buffer.

References application_windows, APPWINDOWS::pOptionsWin, and refresh_options_window().

◆ refresh_windows()

static void refresh_windows ( void  )
static

◆ scroll_window()

static void scroll_window ( int  nCommand,
APPPAD pPad,
void(*)(void)  parent_refresh 
)
static

Scroll a window.

Parameters
nCommandCode for the direction to scroll.
pPadThe window to scroll.
parent_refreshFunction to call to refresh the parent window.

References details_pad, APPPAD::pPad, APPPAD::uiColumns, APPPAD::uiPadCol, APPPAD::uiPadRow, APPPAD::uiRows, APPPAD::uiWinColumns, and APPPAD::uiWinRows.