Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

Framework


Data Structures

struct  CU_Test
 CUnit test case data type. More...
struct  CU_Suite
 CUnit suite data type. More...
struct  CU_TestRegistry
 CUnit test registry data type. More...
struct  CU_TestInfo
 Test case parameters. More...
struct  CU_SuiteInfo
 Suite parameters. More...
struct  test_suite
 Deprecated (version 1). More...
struct  CU_FailureRecord
 Data type for holding assertion failure information (linked list). More...
struct  CU_RunSummary
 Data type for holding statistics and assertion failures for a test run. More...

Defines

#define get_error()   CU_get_error_msg()
 Deprecated (version 1).
#define MAX_TEST_NAME_LENGTH   256
 Maximum length of a test name string.
#define MAX_SUITE_NAME_LENGTH   256
 Maximim length of a suite name string.
#define BOOL   int
 Boolean type for CUnit use.
#define TRUE   1
 Boolean TRUE for CUnit use.
#define FALSE   0
 Boolean FALSE for CUnit use.
#define CU_UNREFERENCED_PARAMETER(x)   (void)x
 Consistent approach to referencing unused parameters.
#define CU_PASS(msg)   { CU_assertImplementation(TRUE, __LINE__, ("CU_PASS(" #msg ")"), __FILE__, "", FALSE); }
 Record a pass condition without performing a logical test.
#define CU_ASSERT(value)   { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", FALSE); }
 Simple assertion.
#define CU_ASSERT_FATAL(value)   { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", TRUE); }
 Simple assertion.
#define CU_TEST(value)   { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", FALSE); }
 Simple assertion.
#define CU_TEST_FATAL(value)   { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", TRUE); }
 Simple assertion.
#define CU_FAIL(msg)   { CU_assertImplementation(FALSE, __LINE__, ("CU_FAIL(" #msg ")"), __FILE__, "", FALSE); }
 Record a failure without performing a logical test.
#define CU_FAIL_FATAL(msg)   { CU_assertImplementation(FALSE, __LINE__, ("CU_FAIL_FATAL(" #msg ")"), __FILE__, "", TRUE); }
 Record a failure without performing a logical test, and abort test.
#define CU_ASSERT_TRUE(value)   { CU_assertImplementation((value), __LINE__, ("CU_ASSERT_TRUE(" #value ")"), __FILE__, "", FALSE); }
 Asserts that value is TRUE.
#define CU_ASSERT_TRUE_FATAL(value)   { CU_assertImplementation((value), __LINE__, ("CU_ASSERT_TRUE_FATAL(" #value ")"), __FILE__, "", TRUE); }
 Asserts that value is TRUE.
#define CU_ASSERT_FALSE(value)   { CU_assertImplementation(!(value), __LINE__, ("CU_ASSERT_FALSE(" #value ")"), __FILE__, "", FALSE); }
 Asserts that value is FALSE.
#define CU_ASSERT_FALSE_FATAL(value)   { CU_assertImplementation(!(value), __LINE__, ("CU_ASSERT_FALSE_FATAL(" #value ")"), __FILE__, "", TRUE); }
 Asserts that value is FALSE.
#define CU_ASSERT_EQUAL(actual, expected)   { CU_assertImplementation(((actual) == (expected)), __LINE__, ("CU_ASSERT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); }
 Asserts that actual == expected.
#define CU_ASSERT_EQUAL_FATAL(actual, expected)   { CU_assertImplementation(((actual) == (expected)), __LINE__, ("CU_ASSERT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", TRUE); }
 Asserts that actual == expected.
#define CU_ASSERT_NOT_EQUAL(actual, expected)   { CU_assertImplementation(((actual) != (expected)), __LINE__, ("CU_ASSERT_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); }
 Asserts that actual != expected.
#define CU_ASSERT_NOT_EQUAL_FATAL(actual, expected)   { CU_assertImplementation(((actual) != (expected)), __LINE__, ("CU_ASSERT_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", TRUE); }
 Asserts that actual != expected.
#define CU_ASSERT_PTR_EQUAL(actual, expected)   { CU_assertImplementation(((void*)(actual) == (void*)(expected)), __LINE__, ("CU_ASSERT_PTR_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); }
 Asserts that pointers actual == expected.
#define CU_ASSERT_PTR_EQUAL_FATAL(actual, expected)   { CU_assertImplementation(((void*)(actual) == (void*)(expected)), __LINE__, ("CU_ASSERT_PTR_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", TRUE); }
 Asserts that pointers actual == expected.
#define CU_ASSERT_PTR_NOT_EQUAL(actual, expected)   { CU_assertImplementation(((void*)(actual) != (void*)(expected)), __LINE__, ("CU_ASSERT_PTR_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); }
 Asserts that pointers actual != expected.
#define CU_ASSERT_PTR_NOT_EQUAL_FATAL(actual, expected)   { CU_assertImplementation(((void*)(actual) != (void*)(expected)), __LINE__, ("CU_ASSERT_PTR_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", TRUE); }
 Asserts that pointers actual != expected.
#define CU_ASSERT_PTR_NULL(value)   { CU_assertImplementation((NULL == (void*)(value)), __LINE__, ("CU_ASSERT_PTR_NULL(" #value")"), __FILE__, "", FALSE); }
 Asserts that pointer value is NULL.
#define CU_ASSERT_PTR_NULL_FATAL(value)   { CU_assertImplementation((NULL == (void*)(value)), __LINE__, ("CU_ASSERT_PTR_NULL_FATAL(" #value")"), __FILE__, "", TRUE); }
 Asserts that pointer value is NULL.
#define CU_ASSERT_PTR_NOT_NULL(value)   { CU_assertImplementation((NULL != (void*)(value)), __LINE__, ("CU_ASSERT_PTR_NOT_NULL(" #value")"), __FILE__, "", FALSE); }
 Asserts that pointer value is not NULL.
#define CU_ASSERT_PTR_NOT_NULL_FATAL(value)   { CU_assertImplementation((NULL != (void*)(value)), __LINE__, ("CU_ASSERT_PTR_NOT_NULL_FATAL(" #value")"), __FILE__, "", TRUE); }
 Asserts that pointer value is not NULL.
#define CU_ASSERT_STRING_EQUAL(actual, expected)   { CU_assertImplementation(!(strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); }
 Asserts that string actual == expected.
#define CU_ASSERT_STRING_EQUAL_FATAL(actual, expected)   { CU_assertImplementation(!(strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", TRUE); }
 Asserts that string actual == expected.
#define CU_ASSERT_STRING_NOT_EQUAL(actual, expected)   { CU_assertImplementation((strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); }
 Asserts that string actual != expected.
#define CU_ASSERT_STRING_NOT_EQUAL_FATAL(actual, expected)   { CU_assertImplementation((strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", TRUE); }
 Asserts that string actual != expected.
#define CU_ASSERT_NSTRING_EQUAL(actual, expected, count)   { CU_assertImplementation(!(strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", FALSE); }
 Asserts that string actual == expected with length specified.
#define CU_ASSERT_NSTRING_EQUAL_FATAL(actual, expected, count)   { CU_assertImplementation(!(strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_EQUAL_FATAL(" #actual "," #expected "," #count ")"), __FILE__, "", TRUE); }
 Asserts that string actual == expected with length specified.
#define CU_ASSERT_NSTRING_NOT_EQUAL(actual, expected, count)   { CU_assertImplementation((strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_NOT_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", FALSE); }
 Asserts that string actual != expected with length specified.
#define CU_ASSERT_NSTRING_NOT_EQUAL_FATAL(actual, expected, count)   { CU_assertImplementation((strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_NOT_EQUAL_FATAL(" #actual "," #expected "," #count ")"), __FILE__, "", TRUE); }
 Asserts that string actual != expected with length specified.
#define CU_ASSERT_DOUBLE_EQUAL(actual, expected, granularity)   { CU_assertImplementation(((fabs((double)(actual) - (expected)) <= fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", FALSE); }
 Asserts that double actual == expected within the specified tolerance.
#define CU_ASSERT_DOUBLE_EQUAL_FATAL(actual, expected, granularity)   { CU_assertImplementation(((fabs((double)(actual) - (expected)) <= fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_EQUAL_FATAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", TRUE); }
 Asserts that double actual == expected within the specified tolerance.
#define CU_ASSERT_DOUBLE_NOT_EQUAL(actual, expected, granularity)   { CU_assertImplementation(((fabs((double)(actual) - (expected)) > fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_NOT_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", FALSE); }
 Asserts that double actual != expected within the specified tolerance.
#define CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL(actual, expected, granularity)   { CU_assertImplementation(((fabs((double)(actual) - (expected)) > fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", TRUE); }
 Asserts that double actual != expected within the specified tolerance.
#define ASSERT(value)   { if (FALSE == (int)(value)) { CU_assertImplementation((BOOL)value, __LINE__, #value, __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_TRUE(value)   { if (FALSE == (value)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_TRUE(" #value ")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_FALSE(value)   { if (FALSE != (value)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_FALSE(" #value ")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_EQUAL(actual, expected)   { if ((actual) != (expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_NOT_EQUAL(actual, expected)   { if ((void*)(actual) == (void*)(expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_PTR_EQUAL(actual, expected)   { if ((void*)(actual) != (void*)(expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_PTR_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_PTR_NOT_EQUAL(actual, expected)   { if ((void*)(actual) == (void*)(expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_PTR_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_PTR_NULL(value)   { if (NULL != (void*)(value)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_PTR_NULL(" #value")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_PTR_NOT_NULL(value)   { if (NULL == (void*)(value)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_PTR_NOT_NULL(" #value")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_STRING_EQUAL(actual, expected)   { if (strcmp((const char*)actual, (const char*)expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_STRING_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_STRING_NOT_EQUAL(actual, expected)   { if (!strcmp((const char*)actual, (const char*)expected)) { CU_assertImplementation(TRUE, __LINE__, ("ASSERT_STRING_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_NSTRING_EQUAL(actual, expected, count)   { if (strncmp((const char*)actual, (const char*)expected, (size_t)count)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_NSTRING_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_NSTRING_NOT_EQUAL(actual, expected, count)   { if (!strncmp((const char*)actual, (const char*)expected, (size_t)count)) { CU_assertImplementation(TRUE, __LINE__, ("ASSERT_NSTRING_NOT_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_DOUBLE_EQUAL(actual, expected, granularity)   { if ((fabs((double)actual - expected) > fabs((double)granularity))) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_DOUBLE_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define ASSERT_DOUBLE_NOT_EQUAL(actual, expected, granularity)   { if ((fabs((double)actual - expected) <= fabs((double)granularity))) { CU_assertImplementation(TRUE, __LINE__, ("ASSERT_DOUBLE_NOT_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", FALSE); return; }}
 Deprecated (version 1).
#define CU_CALLOC(x, y)   calloc((x), (y))
 Standard calloc() if MEMTRACE not defined.
#define CU_MALLOC(x)   malloc((x))
 Standard malloc() if MEMTRACE not defined.
#define CU_FREE(x)   free((x))
 Standard free() if MEMTRACE not defined.
#define CU_REALLOC(x, y)   realloc((x), (y))
 Standard realloc() if MEMTRACE not defined.
#define CU_CREATE_MEMORY_REPORT(x)
 No-op if MEMTRACE not defined.
#define CU_DUMP_MEMORY_USAGE(x)
 No-op if MEMTRACE not defined.
#define CU_ADD_TEST(suite, test)   (CU_add_test(suite, #test, (CU_TestFunc)test))
 Shortcut macro for adding a test to a suite.
#define CU_TEST_INFO_NULL   { NULL, NULL }
 NULL CU_test_info_t to terminate arrays of tests.
#define CU_SUITE_INFO_NULL   { NULL, NULL, NULL, NULL }
 NULL CU_suite_info_t to terminate arrays of suites.
#define TEST_CASE_NULL   { NULL, NULL }
 Deprecated (version 1).
#define TEST_GROUP_NULL   { NULL, NULL, NULL, NULL }
 Deprecated (version 1).
#define test_group_register(tg)   CU_register_suites(tg)
 Deprecated (version 1).
#define initialize_registry()   CU_initialize_registry()
 Deprecated (version 1).
#define cleanup_registry()   CU_cleanup_registry()
 Deprecated (version 1).
#define add_test_group(name, init, clean)   CU_add_suite(name, init, clean)
 Deprecated (version 1).
#define add_test_case(group, name, test)   CU_add_test(group, name, test)
 Deprecated (version 1).
#define get_registry()   CU_get_registry()
 Deprecated (version 1).
#define set_registry(reg)   CU_set_registry((reg))
 Deprecated (version 1).
#define get_group_by_name(group, reg)   CU_get_suite_by_name(group, reg)
 Deprecated (version 1).
#define get_test_by_name(test, group)   CU_get_test_by_name(test, group)
 Deprecated (version 1).
#define ADD_TEST_TO_GROUP(group, test)   (CU_add_test(group, #test, (CU_TestFunc)test))
 Deprecated (version 1).
#define CUNIT_MAX_STRING_LENGTH   1024
 Maximum string length.
#define CUNIT_MAX_ENTITY_LEN   5
 maximum number of characters in a translated xml entity.
#define translate_special_characters(src, dest, len)   CU_translate_special_characters(src, dest, len)
 Deprecated (version 1).
#define compare_strings(src, dest)   CU_compare_strings(src, dest)
 Deprecated (version 1).
#define trim_left(str)   CU_trim_left(str)
 Deprecated (version 1).
#define trim_right(str)   CU_trim_right(str)
 Deprecated (version 1).
#define trim(str)   CU_trim(str)
 Deprecated (version 1).

Typedefs

typedef enum CU_ErrorAction CU_ErrorAction
 CUnit error action codes.
typedef int(* CU_InitializeFunc )(void)
 Signature for suite initialization function.
typedef int(* CU_CleanupFunc )(void)
 Signature for suite cleanup function.
typedef void(* CU_TestFunc )(void)
 Signature for a testing function in a test case.
typedef CU_Test CU_Test
 CUnit test case data type.
typedef CU_TestCU_pTest
 Pointer to a CUnit test case.
typedef CU_Suite CU_Suite
 CUnit suite data type.
typedef CU_SuiteCU_pSuite
 Pointer to a CUnit suite.
typedef CU_TestRegistry CU_TestRegistry
 CUnit test registry data type.
typedef CU_TestRegistryCU_pTestRegistry
 Pointer to a CUnit test registry.
typedef CU_TestInfo CU_TestInfo
 Test case parameters.
typedef CU_TestInfoCU_pTestInfo
 Pointer to CU_TestInfo type.
typedef CU_SuiteInfo CU_SuiteInfo
 Suite parameters.
typedef CU_SuiteInfoCU_pSuiteInfo
 Pointer to CU_SuiteInfo type.
typedef CU_TestInfo test_case_t
 Deprecated (version 1).
typedef CU_SuiteInfo test_group_t
 Deprecated (version 1).
typedef test_suite test_suite_t
 Deprecated (version 1).
typedef CU_InitializeFunc InitializeFunc
 Deprecated (version 1).
typedef CU_CleanupFunc CleanupFunc
 Deprecated (version 1).
typedef CU_TestFunc TestFunc
 Deprecated (version 1).
typedef CU_Test _TestCase
 Deprecated (version 1).
typedef CU_pTest PTestCase
 Deprecated (version 1).
typedef CU_Suite _TestGroup
 Deprecated (version 1).
typedef CU_pSuite PTestGroup
 Deprecated (version 1).
typedef CU_TestRegistry _TestRegistry
 Deprecated (version 1).
typedef CU_pTestRegistry PTestRegistry
 Deprecated (version 1).
typedef CU_FailureRecord CU_FailureRecord
 Data type for holding assertion failure information (linked list).
typedef CU_FailureRecordCU_pFailureRecord
 Pointer to CU_FailureRecord.
typedef CU_RunSummary CU_RunSummary
 Data type for holding statistics and assertion failures for a test run.
typedef CU_RunSummaryCU_pRunSummary
 Pointer to CU_RunSummary.
typedef void(* CU_TestStartMessageHandler )(const CU_pTest pTest, const CU_pSuite pSuite)
 Message handler called at the start of a test.
typedef void(* CU_TestCompleteMessageHandler )(const CU_pTest pTest, const CU_pSuite pSuite, const CU_pFailureRecord pFailure)
 Message handler called at the completion of a test.
typedef void(* CU_AllTestsCompleteMessageHandler )(const CU_pFailureRecord pFailure)
 Message handler called at the completion of a test run.
typedef void(* CU_SuiteInitFailureMessageHandler )(const CU_pSuite pSuite)
 Message handler called when a suite initializer fails.
typedef CU_FailureRecord _TestResult
typedef CU_pFailureRecord PTestResult

Enumerations

enum  CU_ErrorCode {
  CUE_SUCCESS = 0, CUE_NOMEMORY = 1, CUE_NOREGISTRY = 10, CUE_REGISTRY_EXISTS = 11,
  CUE_NOSUITE = 20, CUE_NO_SUITENAME = 21, CUE_SINIT_FAILED = 22, CUE_SCLEAN_FAILED = 23,
  CUE_DUP_SUITE = 24, CUE_NOTEST = 30, CUE_NO_TESTNAME = 31, CUE_DUP_TEST = 32,
  CUE_TEST_NOT_IN_SUITE = 33, CUE_FOPEN_FAILED = 40, CUE_FCLOSE_FAILED = 41, CUE_BAD_FILENAME = 42,
  CUE_WRITE_ERROR = 43
}
 CUnit error codes. More...
enum  CU_ErrorAction { CUEA_IGNORE, CUEA_FAIL, CUEA_ABORT }
 CUnit error action codes. More...

Functions

CU_ErrorCode CU_get_error (void)
 Get the error code.
const char * CU_get_error_msg (void)
 Get the message corresponding to the error code.
void CU_set_error_action (CU_ErrorAction action)
 Set the action to take when an error condition occurs.
CU_ErrorAction CU_get_error_action (void)
 Get the current error action code.
void test_cunit_CUError (void)
void CU_set_error (CU_ErrorCode error)
 Set the error code.
void test_cunit_deactivate_malloc (void)
 Disable memory allocation for testing purposes.
void test_cunit_activate_malloc (void)
 Enable memory allocation for testing purposes.
unsigned int test_cunit_get_n_memevents (void *pLocation)
 Retrieve number of memory events for a given pointer.
unsigned int test_cunit_get_n_allocations (void *pLocation)
 Retrieve number of allocations for a given pointer.
unsigned int test_cunit_get_n_deallocations (void *pLocation)
 Retrieve number of deallocations for a given pointer.
void test_cunit_MyMem (void)
 The main internal testing function for MyMem.c.
CU_ErrorCode CU_initialize_registry (void)
 Initialize the test registry.
void CU_cleanup_registry (void)
 Clear the test registry.
CU_pSuite CU_add_suite (const char *strName, CU_InitializeFunc pInit, CU_CleanupFunc pClean)
 Create a new test suite and add it to the test registry.
CU_pTest CU_add_test (CU_pSuite pSuite, const char *strName, CU_TestFunc pTestFunc)
 Create a new test case and add it to a test suite.
CU_ErrorCode CU_register_suites (CU_SuiteInfo suite_info[])
 Registers the suites in a single CU_SuiteInfo array..
CU_ErrorCode CU_register_nsuites (int suite_count,...)
 Registers multiple suite arrays in CU_SuiteInfo format.
int test_suite_register (test_suite_t *ts)
 Deprecated (version 1).
CU_pTestRegistry CU_get_registry (void)
 Retrieve a pointer to the current test registry.
CU_pTestRegistry CU_set_registry (CU_pTestRegistry pTestRegistry)
 Set the registry to an existing CU_pTestRegistry instance.
CU_pTestRegistry CU_create_new_registry (void)
 Create and initialize a new test registry.
void CU_destroy_existing_registry (CU_pTestRegistry *ppRegistry)
 Destroy and free all memory for an existing test registry.
CU_pSuite CU_get_suite_by_name (const char *szSuiteName, CU_pTestRegistry pRegistry)
 Retrieve a pointer to the suite having the specified name.
CU_pTest CU_get_test_by_name (const char *szTestName, CU_pSuite pSuite)
 Retrieve a pointer to the test case having the specified name.
void test_cunit_TestDB (void)
void CU_set_test_start_handler (CU_TestStartMessageHandler pTestStartMessage)
 Set the message handler to call before each test is run.
void CU_set_test_complete_handler (CU_TestCompleteMessageHandler pTestCompleteMessage)
 Set the message handler to call after each test is run.
void CU_set_all_test_complete_handler (CU_AllTestsCompleteMessageHandler pAllTestsCompleteMessage)
 Set the message handler to call after all tests have been run.
void CU_set_suite_init_failure_handler (CU_SuiteInitFailureMessageHandler pSuiteInitFailureMessage)
 Set the message handler to call when a suite initialization function returns an error.
CU_TestStartMessageHandler CU_get_test_start_handler (void)
 Retrieve the message handler called before each test is run.
CU_TestCompleteMessageHandler CU_get_test_complete_handler (void)
 Retrieve the message handler called after each test is run.
CU_AllTestsCompleteMessageHandler CU_get_all_test_complete_handler (void)
 Retrieve the message handler called after all tests are run.
CU_SuiteInitFailureMessageHandler CU_get_suite_init_failure_handler (void)
 Retrieve the message handler called when a suite initialization error occurs.
CU_ErrorCode CU_run_all_tests (void)
 Run all tests in all suites registered in the test registry.
CU_ErrorCode CU_run_suite (CU_pSuite pSuite)
 Run all tests in a specified suite.
CU_ErrorCode CU_run_test (CU_pSuite pSuite, CU_pTest pTest)
 Run a specific test in a specified suite.
unsigned int CU_get_number_of_suites_run (void)
 Retrieve the number of suites completed during the previous run.
unsigned int CU_get_number_of_suites_failed (void)
 Retrieve the number of suites which failed to initialize during the previous run.
unsigned int CU_get_number_of_tests_run (void)
 Retrieve the number of tests completed during the previous run.
unsigned int CU_get_number_of_tests_failed (void)
 Retrieve the number of tests which contained failed assertions during the previous run.
unsigned int CU_get_number_of_asserts (void)
 Retrieve the number of assertions processed during the last run.
unsigned int CU_get_number_of_successes (void)
 Retrieve the number of successful assertions during the last run.
unsigned int CU_get_number_of_failures (void)
 Retrieve the number of failed assertions during the last run.
unsigned int CU_get_number_of_failure_records (void)
 Retrieve the number failure records created during the previous run.
CU_pFailureRecord CU_get_failure_list (void)
 Retrieve the list of failures which occurred during the last test run.
CU_pRunSummary CU_get_run_summary (void)
 Retrieve the entire run summary for the last test run.
CU_pSuite CU_get_current_suite (void)
 Retrieve a pointer to the currently-running suite (NULL if none).
CU_pTest CU_get_current_test (void)
 Retrieve a pointer to the currently-running test (NULL if none).
BOOL CU_is_test_running (void)
 Returns TRUE if a test run is in progress, TRUE otherwise.
void CU_clear_previous_results (void)
 Initialize the run summary information stored from the previous test run.
BOOL CU_assertImplementation (BOOL bValue, unsigned int uiLine, char strCondition[], char strFile[], char strFunction[], BOOL bFatal)
 Assertion implementation function.
void test_cunit_TestRun (void)
int CU_translate_special_characters (const char *szSrc, char *szDest, int maxlen)
 Convert special characters in the specified string to xml entity codes.
int CU_compare_strings (const char *szSrc, const char *szDest)
 Case-insensitive string comparison.
void CU_trim_left (char *szString)
 Trim leading whitespace from the specified string.
void CU_trim_right (char *szString)
 Trim trailing whitespace from the specified string.
void CU_trim (char *szString)
 Trim leading and trailing whitespace from the specified string.
void test_cunit_Util (void)
const char * get_error_desc (CU_ErrorCode error)
 Internal function to look up the error message for a specified error code.
void cleanup_test_registry (CU_pTestRegistry pRegistry)
 Internal function to clean up the specified test registry.
CU_pSuite create_suite (const char *strName, CU_InitializeFunc pInit, CU_CleanupFunc pClean)
 Internal function to create a new test suite having the specified parameters.
void cleanup_suite (CU_pSuite pSuite)
 Internal function to clean up the specified test suite.
void insert_suite (CU_pTestRegistry pRegistry, CU_pSuite pSuite)
 Internal function to insert a suite into a registry.
CU_pTest create_test (const char *strName, CU_TestFunc pTestFunc)
 Internal function to create a new test case having the specified parameters.
void cleanup_test (CU_pTest pTest)
 Internal function to clean up the specified test.
void insert_test (CU_pSuite pSuite, CU_pTest pTest)
 Internal function to insert a test into a suite.
BOOL suite_exists (CU_pTestRegistry pRegistry, const char *szSuiteName)
 Internal function to check whether a suite having a specified name already exists.
BOOL test_exists (CU_pSuite pSuite, const char *szTestName)
 Internal function to check whether a test having a specified name is already registered in a given suite.
void clear_previous_results (CU_pRunSummary pRunSummary, CU_pFailureRecord *ppFailure)
 Initialize the run summary information in the specified structure.
void cleanup_failure_list (CU_pFailureRecord *ppFailure)
 Free all memory allocated for the linked list of test failure records.
CU_ErrorCode run_single_suite (CU_pSuite pSuite, CU_pRunSummary pRunSummary)
 Run all tests in a specified suite.
CU_ErrorCode run_single_test (CU_pTest pTest, CU_pRunSummary pRunSummary)
 Run a specific test.
void add_failure (CU_pFailureRecord *ppFailure, CU_pRunSummary pRunSummary, unsigned int uiLineNumber, char szCondition[], char szFileName[], CU_pSuite pSuite, CU_pTest pTest)
 Record a failed test.
int get_index (char ch)
 Check whether a character is a special xml character.

Variables

CU_ErrorCode g_error_number = CUE_SUCCESS
 Local variable holding the current error code.
CU_ErrorCode g_error_action = CUEA_IGNORE
 Local variable holding the current error action code.
CU_pTestRegistry f_pTestRegistry = NULL
 The active internal Test Registry.
BOOL f_bTestIsRunning = FALSE
 Flag for whether a test run is in progress.
CU_pSuite f_pCurSuite = NULL
 Pointer to the suite currently being run.
CU_pTest f_pCurTest = NULL
 Pointer to the test currently being run.
CU_RunSummary f_run_summary = {0, 0, 0, 0, 0, 0, 0}
 CU_RunSummary to hold results of each test run.
CU_pFailureRecord f_failure_list = NULL
 CU_pFailureRecord to hold head of failure record list of each test run.
CU_pFailureRecord f_last_failure = NULL
 Keeps track of end of f_run_summary list for message handlers.
CU_TestStartMessageHandler f_pTestStartMessageHandler = NULL
 Pointer to the function to be called before running a test.
CU_TestCompleteMessageHandler f_pTestCompleteMessageHandler = NULL
 Pointer to the function to be called after running a test.
CU_AllTestsCompleteMessageHandler f_pAllTestsCompleteMessageHandler = NULL
 Pointer to the function to be called when all tests have been run.
CU_SuiteInitFailureMessageHandler f_pSuiteInitFailureMessageHandler = NULL
 Pointer to the function to be called if a suite initialization function returns an error.
struct {
   char   special_char
   char *   replacement
bindings
 Structure containing mappings of special characters to xml entity codes.


Define Documentation

#define add_test_case group,
name,
test   )     CU_add_test(group, name, test)
 

Deprecated (version 1).

Deprecated:
Use CU_add_test().

#define add_test_group name,
init,
clean   )     CU_add_suite(name, init, clean)
 

Deprecated (version 1).

Deprecated:
Use CU_add_suite().

#define ADD_TEST_TO_GROUP group,
test   )     (CU_add_test(group, #test, (CU_TestFunc)test))
 

Deprecated (version 1).

Deprecated:
Use ADD_TEST_TO_SUITE.

#define ASSERT value   )     { if (FALSE == (int)(value)) { CU_assertImplementation((BOOL)value, __LINE__, #value, __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_FATAL.

#define ASSERT_DOUBLE_EQUAL actual,
expected,
granularity   )     { if ((fabs((double)actual - expected) > fabs((double)granularity))) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_DOUBLE_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_DOUBLE_EQUAL_FATAL.

#define ASSERT_DOUBLE_NOT_EQUAL actual,
expected,
granularity   )     { if ((fabs((double)actual - expected) <= fabs((double)granularity))) { CU_assertImplementation(TRUE, __LINE__, ("ASSERT_DOUBLE_NOT_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL.

#define ASSERT_EQUAL actual,
expected   )     { if ((actual) != (expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_EQUAL_FATAL.

#define ASSERT_FALSE value   )     { if (FALSE != (value)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_FALSE(" #value ")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_FALSE_FATAL.

#define ASSERT_NOT_EQUAL actual,
expected   )     { if ((void*)(actual) == (void*)(expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_NOT_EQUAL_FATAL.

#define ASSERT_NSTRING_EQUAL actual,
expected,
count   )     { if (strncmp((const char*)actual, (const char*)expected, (size_t)count)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_NSTRING_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_NSTRING_EQUAL_FATAL.

#define ASSERT_NSTRING_NOT_EQUAL actual,
expected,
count   )     { if (!strncmp((const char*)actual, (const char*)expected, (size_t)count)) { CU_assertImplementation(TRUE, __LINE__, ("ASSERT_NSTRING_NOT_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_NSTRING_NOT_EQUAL_FATAL.

#define ASSERT_PTR_EQUAL actual,
expected   )     { if ((void*)(actual) != (void*)(expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_PTR_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_PTR_EQUAL_FATAL.

#define ASSERT_PTR_NOT_EQUAL actual,
expected   )     { if ((void*)(actual) == (void*)(expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_PTR_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_PTR_NOT_EQUAL_FATAL.

#define ASSERT_PTR_NOT_NULL value   )     { if (NULL == (void*)(value)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_PTR_NOT_NULL(" #value")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_PTR_NOT_NULL_FATAL.

#define ASSERT_PTR_NULL value   )     { if (NULL != (void*)(value)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_PTR_NULL(" #value")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_PTR_NULL_FATAL.

#define ASSERT_STRING_EQUAL actual,
expected   )     { if (strcmp((const char*)actual, (const char*)expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_STRING_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_STRING_EQUAL_FATAL.

#define ASSERT_STRING_NOT_EQUAL actual,
expected   )     { if (!strcmp((const char*)actual, (const char*)expected)) { CU_assertImplementation(TRUE, __LINE__, ("ASSERT_STRING_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_STRING_NOT_EQUAL_FATAL.

#define ASSERT_TRUE value   )     { if (FALSE == (value)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_TRUE(" #value ")"), __FILE__, "", FALSE); return; }}
 

Deprecated (version 1).

Deprecated:
Use CU_ASSERT_TRUE_FATAL.

#define BOOL   int
 

Boolean type for CUnit use.

 
#define cleanup_registry  )     CU_cleanup_registry()
 

Deprecated (version 1).

Deprecated:
Use CU_cleanup_registry().

#define compare_strings src,
dest   )     CU_compare_strings(src, dest)
 

Deprecated (version 1).

Deprecated:
Use CU_compare_strings().

#define CU_ADD_TEST suite,
test   )     (CU_add_test(suite, #test, (CU_TestFunc)test))
 

Shortcut macro for adding a test to a suite.

#define CU_ASSERT value   )     { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", FALSE); }
 

Simple assertion.

Reports failure with no other action.

#define CU_ASSERT_DOUBLE_EQUAL actual,
expected,
granularity   )     { CU_assertImplementation(((fabs((double)(actual) - (expected)) <= fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", FALSE); }
 

Asserts that double actual == expected within the specified tolerance.

If actual is within granularity of expected, the assertion passes. Reports failure with no other action.

#define CU_ASSERT_DOUBLE_EQUAL_FATAL actual,
expected,
granularity   )     { CU_assertImplementation(((fabs((double)(actual) - (expected)) <= fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_EQUAL_FATAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", TRUE); }
 

Asserts that double actual == expected within the specified tolerance.

If actual is within granularity of expected, the assertion passes. Reports failure and causes test to abort.

#define CU_ASSERT_DOUBLE_NOT_EQUAL actual,
expected,
granularity   )     { CU_assertImplementation(((fabs((double)(actual) - (expected)) > fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_NOT_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", FALSE); }
 

Asserts that double actual != expected within the specified tolerance.

If actual is within granularity of expected, the assertion fails. Reports failure with no other action.

#define CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL actual,
expected,
granularity   )     { CU_assertImplementation(((fabs((double)(actual) - (expected)) > fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", TRUE); }
 

Asserts that double actual != expected within the specified tolerance.

If actual is within granularity of expected, the assertion fails. Reports failure and causes test to abort.

#define CU_ASSERT_EQUAL actual,
expected   )     { CU_assertImplementation(((actual) == (expected)), __LINE__, ("CU_ASSERT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); }
 

Asserts that actual == expected.

Reports failure with no other action.

#define CU_ASSERT_EQUAL_FATAL actual,
expected   )     { CU_assertImplementation(((actual) == (expected)), __LINE__, ("CU_ASSERT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", TRUE); }
 

Asserts that actual == expected.

Reports failure and causes test to abort.

#define CU_ASSERT_FALSE value   )     { CU_assertImplementation(!(value), __LINE__, ("CU_ASSERT_FALSE(" #value ")"), __FILE__, "", FALSE); }
 

Asserts that value is FALSE.

Reports failure with no other action.

#define CU_ASSERT_FALSE_FATAL value   )     { CU_assertImplementation(!(value), __LINE__, ("CU_ASSERT_FALSE_FATAL(" #value ")"), __FILE__, "", TRUE); }
 

Asserts that value is FALSE.

Reports failure and causes test to abort.

#define CU_ASSERT_FATAL value   )     { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", TRUE); }
 

Simple assertion.

Reports failure and causes test to abort.

#define CU_ASSERT_NOT_EQUAL actual,
expected   )     { CU_assertImplementation(((actual) != (expected)), __LINE__, ("CU_ASSERT_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); }
 

Asserts that actual != expected.

Reports failure with no other action.

#define CU_ASSERT_NOT_EQUAL_FATAL actual,
expected   )     { CU_assertImplementation(((actual) != (expected)), __LINE__, ("CU_ASSERT_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", TRUE); }
 

Asserts that actual != expected.

Reports failure and causes test to abort.

#define CU_ASSERT_NSTRING_EQUAL actual,
expected,
count   )     { CU_assertImplementation(!(strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", FALSE); }
 

Asserts that string actual == expected with length specified.

The comparison is limited to count characters. Reports failure with no other action.

#define CU_ASSERT_NSTRING_EQUAL_FATAL actual,
expected,
count   )     { CU_assertImplementation(!(strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_EQUAL_FATAL(" #actual "," #expected "," #count ")"), __FILE__, "", TRUE); }
 

Asserts that string actual == expected with length specified.

The comparison is limited to count characters. Reports failure and causes test to abort.

#define CU_ASSERT_NSTRING_NOT_EQUAL actual,
expected,
count   )     { CU_assertImplementation((strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_NOT_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", FALSE); }
 

Asserts that string actual != expected with length specified.

The comparison is limited to count characters. Reports failure with no other action.

#define CU_ASSERT_NSTRING_NOT_EQUAL_FATAL actual,
expected,
count   )     { CU_assertImplementation((strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_NOT_EQUAL_FATAL(" #actual "," #expected "," #count ")"), __FILE__, "", TRUE); }
 

Asserts that string actual != expected with length specified.

The comparison is limited to count characters. Reports failure and causes test to abort.

#define CU_ASSERT_PTR_EQUAL actual,
expected   )     { CU_assertImplementation(((void*)(actual) == (void*)(expected)), __LINE__, ("CU_ASSERT_PTR_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); }
 

Asserts that pointers actual == expected.

Reports failure with no other action.

#define CU_ASSERT_PTR_EQUAL_FATAL actual,
expected   )     { CU_assertImplementation(((void*)(actual) == (void*)(expected)), __LINE__, ("CU_ASSERT_PTR_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", TRUE); }
 

Asserts that pointers actual == expected.

Reports failure and causes test to abort.

#define CU_ASSERT_PTR_NOT_EQUAL actual,
expected   )     { CU_assertImplementation(((void*)(actual) != (void*)(expected)), __LINE__, ("CU_ASSERT_PTR_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); }
 

Asserts that pointers actual != expected.

Reports failure with no other action.

#define CU_ASSERT_PTR_NOT_EQUAL_FATAL actual,
expected   )     { CU_assertImplementation(((void*)(actual) != (void*)(expected)), __LINE__, ("CU_ASSERT_PTR_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", TRUE); }
 

Asserts that pointers actual != expected.

Reports failure and causes test to abort.

#define CU_ASSERT_PTR_NOT_NULL value   )     { CU_assertImplementation((NULL != (void*)(value)), __LINE__, ("CU_ASSERT_PTR_NOT_NULL(" #value")"), __FILE__, "", FALSE); }
 

Asserts that pointer value is not NULL.

Reports failure with no other action.

#define CU_ASSERT_PTR_NOT_NULL_FATAL value   )     { CU_assertImplementation((NULL != (void*)(value)), __LINE__, ("CU_ASSERT_PTR_NOT_NULL_FATAL(" #value")"), __FILE__, "", TRUE); }
 

Asserts that pointer value is not NULL.

Reports failure and causes test to abort.

#define CU_ASSERT_PTR_NULL value   )     { CU_assertImplementation((NULL == (void*)(value)), __LINE__, ("CU_ASSERT_PTR_NULL(" #value")"), __FILE__, "", FALSE); }
 

Asserts that pointer value is NULL.

Reports failure with no other action.

#define CU_ASSERT_PTR_NULL_FATAL value   )     { CU_assertImplementation((NULL == (void*)(value)), __LINE__, ("CU_ASSERT_PTR_NULL_FATAL(" #value")"), __FILE__, "", TRUE); }
 

Asserts that pointer value is NULL.

Reports failure and causes test to abort.

#define CU_ASSERT_STRING_EQUAL actual,
expected   )     { CU_assertImplementation(!(strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); }
 

Asserts that string actual == expected.

Reports failure with no other action.

#define CU_ASSERT_STRING_EQUAL_FATAL actual,
expected   )     { CU_assertImplementation(!(strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", TRUE); }
 

Asserts that string actual == expected.

Reports failure and causes test to abort.

#define CU_ASSERT_STRING_NOT_EQUAL actual,
expected   )     { CU_assertImplementation((strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); }
 

Asserts that string actual != expected.

Reports failure with no other action.

#define CU_ASSERT_STRING_NOT_EQUAL_FATAL actual,
expected   )     { CU_assertImplementation((strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", TRUE); }
 

Asserts that string actual != expected.

Reports failure and causes test to abort.

#define CU_ASSERT_TRUE value   )     { CU_assertImplementation((value), __LINE__, ("CU_ASSERT_TRUE(" #value ")"), __FILE__, "", FALSE); }
 

Asserts that value is TRUE.

Reports failure with no other action.

#define CU_ASSERT_TRUE_FATAL value   )     { CU_assertImplementation((value), __LINE__, ("CU_ASSERT_TRUE_FATAL(" #value ")"), __FILE__, "", TRUE); }
 

Asserts that value is TRUE.

Reports failure and causes test to abort.

#define CU_CALLOC x,
 )     calloc((x), (y))
 

Standard calloc() if MEMTRACE not defined.

#define CU_CREATE_MEMORY_REPORT  ) 
 

No-op if MEMTRACE not defined.

#define CU_DUMP_MEMORY_USAGE  ) 
 

No-op if MEMTRACE not defined.

#define CU_FAIL msg   )     { CU_assertImplementation(FALSE, __LINE__, ("CU_FAIL(" #msg ")"), __FILE__, "", FALSE); }
 

Record a failure without performing a logical test.

#define CU_FAIL_FATAL msg   )     { CU_assertImplementation(FALSE, __LINE__, ("CU_FAIL_FATAL(" #msg ")"), __FILE__, "", TRUE); }
 

Record a failure without performing a logical test, and abort test.

#define CU_FREE  )     free((x))
 

Standard free() if MEMTRACE not defined.

#define CU_MALLOC  )     malloc((x))
 

Standard malloc() if MEMTRACE not defined.

#define CU_PASS msg   )     { CU_assertImplementation(TRUE, __LINE__, ("CU_PASS(" #msg ")"), __FILE__, "", FALSE); }
 

Record a pass condition without performing a logical test.

#define CU_REALLOC x,
 )     realloc((x), (y))
 

Standard realloc() if MEMTRACE not defined.

#define CU_SUITE_INFO_NULL   { NULL, NULL, NULL, NULL }
 

NULL CU_suite_info_t to terminate arrays of suites.

#define CU_TEST value   )     { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", FALSE); }
 

Simple assertion.

Reports failure with no other action.

#define CU_TEST_FATAL value   )     { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", TRUE); }
 

Simple assertion.

Reports failure and causes test to abort.

#define CU_TEST_INFO_NULL   { NULL, NULL }
 

NULL CU_test_info_t to terminate arrays of tests.

#define CU_UNREFERENCED_PARAMETER  )     (void)x
 

Consistent approach to referencing unused parameters.

#define CUNIT_MAX_ENTITY_LEN   5
 

maximum number of characters in a translated xml entity.

#define CUNIT_MAX_STRING_LENGTH   1024
 

Maximum string length.

#define FALSE   0
 

Boolean FALSE for CUnit use.

 
#define get_error  )     CU_get_error_msg()
 

Deprecated (version 1).

Deprecated:
Use CU_get_error_msg().

#define get_group_by_name group,
reg   )     CU_get_suite_by_name(group, reg)
 

Deprecated (version 1).

Deprecated:
Use CU_get_suite_by_name().

 
#define get_registry  )     CU_get_registry()
 

Deprecated (version 1).

Deprecated:
Use CU_get_registry().

#define get_test_by_name test,
group   )     CU_get_test_by_name(test, group)
 

Deprecated (version 1).

Deprecated:
Use CU_get_test_by_name().

 
#define initialize_registry  )     CU_initialize_registry()
 

Deprecated (version 1).

Deprecated:
Use CU_initialize_registry().

#define MAX_SUITE_NAME_LENGTH   256
 

Maximim length of a suite name string.

#define MAX_TEST_NAME_LENGTH   256
 

Maximum length of a test name string.

#define set_registry reg   )     CU_set_registry((reg))
 

Deprecated (version 1).

Deprecated:
Use CU_set_registry().

#define TEST_CASE_NULL   { NULL, NULL }
 

Deprecated (version 1).

Deprecated:
Use CU_TEST_INFO_NULL.

#define TEST_GROUP_NULL   { NULL, NULL, NULL, NULL }
 

Deprecated (version 1).

Deprecated:
Use CU_TEST_GROUP_NULL.

#define test_group_register tg   )     CU_register_suites(tg)
 

Deprecated (version 1).

Deprecated:
Use CU_register_suites().

#define translate_special_characters src,
dest,
len   )     CU_translate_special_characters(src, dest, len)
 

Deprecated (version 1).

Deprecated:
Use CU_translate_special_characters().

#define trim str   )     CU_trim(str)
 

Deprecated (version 1).

Deprecated:
Use CU_trim().

#define trim_left str   )     CU_trim_left(str)
 

Deprecated (version 1).

Deprecated:
Use CU_trim_left().

#define trim_right str   )     CU_trim_right(str)
 

Deprecated (version 1).

Deprecated:
Use CU_trim_right().

#define TRUE   1
 

Boolean TRUE for CUnit use.


Typedef Documentation

typedef CU_Test _TestCase
 

Deprecated (version 1).

Deprecated:
Use CU_Test.

typedef CU_Suite _TestGroup
 

Deprecated (version 1).

Deprecated:
Use CU_Suite.

typedef CU_TestRegistry _TestRegistry
 

Deprecated (version 1).

Deprecated:
Use CU_TestRegistry.

typedef CU_FailureRecord _TestResult
 

Deprecated:
Use CU_FailureRecord.

typedef CU_CleanupFunc CleanupFunc
 

Deprecated (version 1).

Deprecated:
Use CU_CleanupFunc.

typedef void(* CU_AllTestsCompleteMessageHandler)(const CU_pFailureRecord pFailure)
 

Message handler called at the completion of a test run.

The parameter is a pointer to the linked list holding the failure records for the test run. The test run is considered completed when the message handler is called.

typedef int(* CU_CleanupFunc)(void)
 

Signature for suite cleanup function.

typedef enum CU_ErrorAction CU_ErrorAction
 

CUnit error action codes.

These are used to set the action desired when an error condition is detected in the CUnit framework.

See also:
CU_set_error_action()

CU_get_error_action()

typedef struct CU_FailureRecord CU_FailureRecord
 

Data type for holding assertion failure information (linked list).

typedef int(* CU_InitializeFunc)(void)
 

Signature for suite initialization function.

typedef CU_FailureRecord* CU_pFailureRecord
 

Pointer to CU_FailureRecord.

typedef CU_RunSummary* CU_pRunSummary
 

Pointer to CU_RunSummary.

typedef CU_Suite* CU_pSuite
 

Pointer to a CUnit suite.

typedef CU_SuiteInfo* CU_pSuiteInfo
 

Pointer to CU_SuiteInfo type.

typedef CU_Test* CU_pTest
 

Pointer to a CUnit test case.

typedef CU_TestInfo* CU_pTestInfo
 

Pointer to CU_TestInfo type.

typedef CU_TestRegistry* CU_pTestRegistry
 

Pointer to a CUnit test registry.

typedef struct CU_RunSummary CU_RunSummary
 

Data type for holding statistics and assertion failures for a test run.

typedef struct CU_Suite CU_Suite
 

CUnit suite data type.

CU_Suite is a linked list of CU_Test containers. Each suite has a name and count of associated unit tests. It also holds a pointer to optional initialization and cleanup functions. If non-NULL, these are called before and after running the suite's tests, respectively. In addition, the suite holds a pointer to the head of the linked list of associated CU_Test objects. Finally, pointers to the next and previous suites in the linked list are maintained.

Generally, the linked list includes suites which are associated with each other in a CU_TestRegistry. As a result, suites are run in the order in which they are registered (see CU_add_suite()).

In the current implementation, the name of each CU_Suite in a test registry must have a unique name. There is no restriction on the contained tests. This means that the same CU_Test could, in principle, be run more than once as long as it is registered with different suites having distinct names.

See also:
CU_Test

CU_TestRegistry

typedef struct CU_SuiteInfo CU_SuiteInfo
 

Suite parameters.

This data type is provided to assist CUnit users manage collections of test and suites. It is intended to be used to build arrays of suite parameters that can be passed to a bulk registration function such as CU_register_suite() or CU_register_suites().

typedef void(* CU_SuiteInitFailureMessageHandler)(const CU_pSuite pSuite)
 

Message handler called when a suite initializer fails.

The test run is considered in progress when the message handler is called.

typedef struct CU_Test CU_Test
 

CUnit test case data type.

CU_Test is a linked list of unit tests. Each test has a name and a callable test function, as well as links to the next and previous tests in the list. A test also holds a jmp_buf reference for use in implementing fatal assertions.

Generally, the linked list includes tests which are associated with each other in a CU_Suite. As a result, tests are run in the order in which they are added to a suite (see CU_add_test()).

In the current implementation, the name of each CU_Test in a suite must have a unique name. There is no restriction on the test function. This means that the same function could, in principle, be called more than once as long as it is registered with different tests having distinct names.

See also:
CU_Suite

CU_TestRegistry

typedef void(* CU_TestCompleteMessageHandler)(const CU_pTest pTest, const CU_pSuite pSuite, const CU_pFailureRecord pFailure)
 

Message handler called at the completion of a test.

The parameters are the test and suite being run, plus a pointer to the first failure record applicable to this test. If the test did not have any assertion failures, pFailure will be NULL. The test run is considered in progress when the message handler is called.

typedef void(* CU_TestFunc)(void)
 

Signature for a testing function in a test case.

typedef struct CU_TestInfo CU_TestInfo
 

Test case parameters.

This data type is provided to assist CUnit users manage collections of test and suites. It is intended to be used to build arrays of test case parameters that can be then be referred to in a CU_suite_info_t variable.

typedef struct CU_TestRegistry CU_TestRegistry
 

CUnit test registry data type.

CU_TestRegisty is the repository for suites containing unit tests. The test registry maintains a count of the number of CU_Suite objects contained in the registry, as well as a count of the total number of CU_Test objects associated with those suites. It also holds a pointer to the head of the linked list of CU_Suite objects.

With this structure, the user will normally add suites implictly to the internal test registry using CU_add_suite(), and then add tests to each suite using CU_add_test(). Test runs are then initiated using one of the appropriate functions in TestRun.c via one of the interfaces.

Automatic creation and destruction of the internal registry and its objects is available using CU_initialize_registry() and CU_cleanup_registry(), respectively. For internal and testing purposes, the internal registry can be retrieved and assigned. Functions are also provided for creating and destroying independent registries.

Note that earlier versions of CUnit also contained a pointer to a linked list of CU_FailureRecord objects (termed _TestResults). This has been removed from the registry and relocated to TestRun.c.

See also:
CU_Test

CU_Suite

CU_initialize_registry()

CU_cleanup_registry()

CU_get_registry()

CU_set_registry()

CU_create_new_registry()

CU_destroy_existing_registry()

typedef void(* CU_TestStartMessageHandler)(const CU_pTest pTest, const CU_pSuite pSuite)
 

Message handler called at the start of a test.

The parameters are the test and suite being run. The test run is considered in progress when the message handler is called.

typedef CU_InitializeFunc InitializeFunc
 

Deprecated (version 1).

Deprecated:
Use CU_InitializeFunc.

typedef CU_pTest PTestCase
 

Deprecated (version 1).

Deprecated:
Use CU_pTest.

typedef CU_pSuite PTestGroup
 

Deprecated (version 1).

Deprecated:
Use CU_pSuite.

typedef CU_pTestRegistry PTestRegistry
 

Deprecated (version 1).

Deprecated:
Use CU_pTestRegistry.

typedef CU_pFailureRecord PTestResult
 

Deprecated:
Use CU_pFailureRecord.

typedef CU_TestInfo test_case_t
 

Deprecated (version 1).

Deprecated:
Use CU_TestInfo.

typedef CU_SuiteInfo test_group_t
 

Deprecated (version 1).

Deprecated:
Use CU_SuiteInfo.

typedef struct test_suite test_suite_t
 

Deprecated (version 1).

Deprecated:
Use CU_SuiteInfo and CU_TestInfo.

typedef CU_TestFunc TestFunc
 

Deprecated (version 1).

Deprecated:
Use CU_TestFunc.


Enumeration Type Documentation

enum CU_ErrorAction
 

CUnit error action codes.

These are used to set the action desired when an error condition is detected in the CUnit framework.

See also:
CU_set_error_action()

CU_get_error_action()

Enumeration values:
CUEA_IGNORE  Runs should be continued when an error condition occurs (if possible).
CUEA_FAIL  Runs should be stopped when an error condition occurs.
CUEA_ABORT  The application should exit() when an error conditions occurs.

enum CU_ErrorCode
 

CUnit error codes.

If codes are added or removed, be sure to make a change to the error messages in CUError.c/get_error_desc().

See also:
CU_set_error()

CU_get_error()

CU_get_error_msg()

Enumeration values:
CUE_SUCCESS  No error condition.
CUE_NOMEMORY  Memory allocation failed.
CUE_NOREGISTRY  Test registry not initialized.
CUE_REGISTRY_EXISTS  Attempt to CU_set_registry() without CU_cleanup_registry().
CUE_NOSUITE  A required CU_pSuite pointer was NULL.
CUE_NO_SUITENAME  Required CU_Suite name not provided.
CUE_SINIT_FAILED  Suite initialization failed.
CUE_SCLEAN_FAILED  Suite cleanup failed.
CUE_DUP_SUITE  Duplicate suite name not allowed.
CUE_NOTEST  A required CU_pTest pointer was NULL.
CUE_NO_TESTNAME  Required CU_Test name not provided.
CUE_DUP_TEST  Duplicate test case name not allowed.
CUE_TEST_NOT_IN_SUITE  Test not registered in specified suite.
CUE_FOPEN_FAILED  An error occurred opening a file.
CUE_FCLOSE_FAILED  An error occurred closing a file.
CUE_BAD_FILENAME  A bad filename was requested (NULL, empty, nonexistent, etc.).
CUE_WRITE_ERROR  An error occurred during a write to a file.


Function Documentation

void add_failure CU_pFailureRecord ppFailure,
CU_pRunSummary  pRunSummary,
unsigned int  uiLineNumber,
char  szCondition[],
char  szFileName[],
CU_pSuite  pSuite,
CU_pTest  pTest
[static]
 

Record a failed test.

This function is called whenever a test fails to record the details of the failure. This includes user assertion failures and system errors such as failure to initialize a suite.

Parameters:
ppFailure Pointer to head of linked list of failure records to append with new failure record. If NULL, it will be set to point to the new failure record.
pRunSummary Pointer to CU_RunSummary keeping track of failure records (ignored if NULL).
uiLineNumber Line number of the failure, if applicable.
szCondition Description of failure condition
szFileName Name of file, if applicable
pSuite The suite being run at time of failure
pTest The test being run at time of failure

void cleanup_failure_list CU_pFailureRecord ppFailure  )  [static]
 

Free all memory allocated for the linked list of test failure records.

pFailure is reset to NULL after its list is cleaned up.

Parameters:
ppFailure Pointer to head of linked list of CU_pFailureRecords to clean.
See also:
CU_clear_previous_results()

void cleanup_suite CU_pSuite  pSuite  )  [static]
 

Internal function to clean up the specified test suite.

Each test case registered with pSuite will be freed. Severe problems can occur if this function is called during a test run involving pSuite.

See also:
cleanup_test_registry()

cleanup_test()

Parameters:
pSuite CU_pSuite to clean up (non-NULL).

void cleanup_test CU_pTest  pTest  )  [static]
 

Internal function to clean up the specified test.

All memory associated with the test will be freed. Severe problems can occur if this function is called during a test run involving pTest.

See also:
cleanup_test_registry()

cleanup_suite()

Parameters:
pTest CU_pTest to clean up (non-NULL).

void cleanup_test_registry CU_pTestRegistry  pRegistry  )  [static]
 

Internal function to clean up the specified test registry.

cleanup_suite() will be called for each registered suite to perform cleanup of the associated test cases. Then, the suite's memory will be freed. Note that any pointers to tests or suites in pRegistry held by the user will be invalidated by this function. Severe problems can occur if this function is called during a test run involving pRegistry. Note that memory held for data members in the registry (e.g. pName) and the registry itself are not freed by this function.

See also:
cleanup_suite()

cleanup_test()

Parameters:
pRegistry CU_pTestRegistry to clean up (non-NULL).

void clear_previous_results CU_pRunSummary  pRunSummary,
CU_pFailureRecord ppFailure
[static]
 

Initialize the run summary information in the specified structure.

Resets the run counts to zero, and calls cleanup_failure_list() if failures were recorded by the last test run. Calling this function multiple times, while inefficient, will not cause an error condition.

Parameters:
pRunSummary CU_RunSummary to initialize.
See also:
CU_clear_previous_results()

CU_pSuite create_suite const char *  strName,
CU_InitializeFunc  pInit,
CU_CleanupFunc  pClean
[static]
 

Internal function to create a new test suite having the specified parameters.

This function creates a new test suite having the specified name and initialization/cleanup functions. The strName cannot be NULL (checked by assertion), but either or both function pointers can be. A pointer to the newly-created suite is returned, or NULL if there was an error allocating memory for the new suite. It is the responsibility of the caller to destroy the returned suite (use cleanup_suite() before freeing the returned pointer).

Parameters:
strName Name for the new test suite (non-NULL).
pInit Initialization function to call before running suite.
pClean Cleanup function to call after running suite.
Returns:
A pointer to the newly-created suite (NULL if creation failed)

CU_pTest create_test const char *  strName,
CU_TestFunc  pTestFunc
[static]
 

Internal function to create a new test case having the specified parameters.

This function creates a new test having the specified name and test function. The strName cannot be NULL (checked by assertion), but the function pointer may be. A pointer to the newly-created test is returned, or NULL if there was an error allocating memory for the new test. It is the responsibility of the caller to destroy the returned test (use cleanup_test() before freeing the returned pointer).

Parameters:
strName Name for the new test.
pTestFunc Test function to call when running this test.
Returns:
A pointer to the newly-created test (NULL if creation failed)

CU_pSuite CU_add_suite const char *  strName,
CU_InitializeFunc  pInit,
CU_CleanupFunc  pClean
 

Create a new test suite and add it to the test registry.

This function creates a new test suite having the specified name and initialization/cleanup functions and adds it to the test registry. It returns a pointer to the newly-created suite, which will be NULL if there was a problem with the suite creation or addition.<br /><br /> CU_add_suite() sets the following error codes: -CUE_NOREGISTRY if the registry hasn't been initialized. -CUE_NO_SUITENAME if strName is NULL. -CUE_DUP_SUITE if a suite having strName is already registered. -CUE_NOMEMORY if a memory allocation failed.<BR /><BR /> NOTE - the CU_pSuite pointer returned should NOT BE FREED BY THE USER. The suite is freed by the CUnit system when CU_cleanup_registry() is called.

This function must not be called during a test run (checked by assertion).

Parameters:
strName Name for the new test suite (unique, non-NULL).
pInit Initialization function to call before running suite.
pClean Cleanup function to call after running suite.
Returns:
A pointer to the newly-created suite (NULL if creation failed)

CU_pTest CU_add_test CU_pSuite  pSuite,
const char *  strName,
CU_TestFunc  pTestFunc
 

Create a new test case and add it to a test suite.

This function creates a new test having the specified name and function, and adds it to the specified suite. At present, there is no mechanism for creating a test case independent of a suite, although this function does return a pointer to the newly-created test.<br /><br /> CU_add_test() sets the following error codes: -CUE_NOSUITE if pSuite is NULL. -CUE_NO_TESTNAME if strName is NULL. -CUE_DUP_TEST if a test having strName is already registered to pSuite. -CUE_NOMEMORY if a memory allocation failed.<BR /><BR /> NOTE - the CU_pTest pointer returned should NOT BE FREED BY THE USER. The test is freed by the CUnit system when CU_cleanup_registry() is called.

This function must not be called during a test run (checked by assertion).

Parameters:
pSuite Test suite to which to add new test.
strName Name for the new test case (unique to pSuite, non-NULL).
pTest Function to call when running the test.
Returns:
A pointer to the newly-created test (NULL if creation failed)

BOOL CU_assertImplementation BOOL  bValue,
unsigned int  uiLine,
char  strCondition[],
char  strFile[],
char  strFunction[],
BOOL  bFatal
 

Assertion implementation function.

All CUnit assertions reduce to a call to this function. It should only be called during an active test run (checked by assertion). This means that CUnit assertions should only be used in registered test functions during a test run.

Parameters:
bValue Value of the assertion (TRUE or FALSE).
uiLine Line number of failed test statement.
strCondition String containing logical test that failed.
strFile Source file where test statement failed.
strFunction Function where test statement failed.
bFatal TRUE to abort test (via longjmp()), FALSE to continue test.
Returns:
As a convenience, returns the value of the assertion.

void CU_cleanup_registry void   ) 
 

Clear the test registry.

The active test registry is freed, including all stored suites and associated tests. The most recent stored test results are also cleared. After calling this function, CUnit suites cannot be added until CU_initialize_registry() or CU_set_registry() is called. Further, any pointers to suites or test cases held by the user will be invalidated by calling this function.

This function may be called multiple times without generating an error condition. However, this function must not be called during a test run (checked by assertion).

See also:
CU_initialize_registry

CU_get_registry

CU_set_registry

void CU_clear_previous_results void   ) 
 

Initialize the run summary information stored from the previous test run.

Resets the run counts to zero, and frees any memory associated with failure records. Calling this function multiple times, while inefficient, will not cause an error condition.

See also:
clear_previous_results()

int CU_compare_strings const char *  szSrc,
const char *  szDest
 

Case-insensitive string comparison.

Parameters:
szSrc 1st string to compare.
szDest 2nd string to compare.
Returns:
NULL if the strings are equal, non-NULL otherwise.

CU_pTestRegistry CU_create_new_registry void   ) 
 

Create and initialize a new test registry.

Returns a pointer to a new, initialized registry (NULL if memory could not be allocated). It is the caller's responsibility to destroy and free the new registry (unless it is made the active test registry using CU_set_registry().

void CU_destroy_existing_registry CU_pTestRegistry ppRegistry  ) 
 

Destroy and free all memory for an existing test registry.

The active test registry is destroyed by the CUnit system in CU_cleanup_registry(), so only call this function on registries created independently of the internal CUnit system. Once a registry is made the active test registry using CU_set_registry(), its destruction will be handled by the framework. Passing a NULL *ppRegistry will have no effect.

Parameters:
ppRegistry Address of a pointer to the registry to destroy.

CU_AllTestsCompleteMessageHandler CU_get_all_test_complete_handler void   ) 
 

Retrieve the message handler called after all tests are run.

CU_pSuite CU_get_current_suite void   ) 
 

Retrieve a pointer to the currently-running suite (NULL if none).

CU_pTest CU_get_current_test void   ) 
 

Retrieve a pointer to the currently-running test (NULL if none).

CU_ErrorCode CU_get_error void   ) 
 

Get the error code.

CUnit implementation functions set the error code to indicate the status of the most recent operation. In general, the CUnit functions will clear the code to CUE_SUCCESS, then reset it to a specific error code if an exception condition is encountered. Some functions return the code, others leave it to the user to inspect if desired.

Returns:
The current error condition code.
See also:
CU_get_error_msg()

CU_ErrorCode

CU_ErrorAction CU_get_error_action void   ) 
 

Get the current error action code.

Returns:
The current error action code.
See also:
CU_set_error_action()

CU_set_error()

CU_ErrorAction

const char * CU_get_error_msg void   ) 
 

Get the message corresponding to the error code.

CUnit implementation functions set the error code to indicate the of the most recent operation. In general, the CUnit functions will clear the code to CUE_SUCCESS, then reset it to a specific error code if an exception condition is encountered. This function allows the user to retrieve a descriptive error message corresponding to the error code set by the last operation.

Returns:
A message corresponding to the current error condition.
See also:
CU_get_error()

CU_ErrorCode

CU_pFailureRecord CU_get_failure_list void   ) 
 

Retrieve the list of failures which occurred during the last test run.

Note that the pointer returned is invalidated when the client initiates a run using CU_run_all_tests(), CU_run_suite(), or CU_run_test().

See also:
CU_get_number_of_successes()

unsigned int CU_get_number_of_asserts void   ) 
 

Retrieve the number of assertions processed during the last run.

The count is reset each time the client initiates a run.

See also:
CU_get_number_of_successes()

CU_get_number_of_failures()

unsigned int CU_get_number_of_failure_records void   ) 
 

Retrieve the number failure records created during the previous run.

Note that this may be more than the number of failed assertions, since failure records may also be created for failed suite initialization and cleanup. The count is reset each time the client initiates a run.

unsigned int CU_get_number_of_failures void   ) 
 

Retrieve the number of failed assertions during the last run.

The count is reset each time the client initiates a run.

See also:
CU_get_number_of_successes()

unsigned int CU_get_number_of_successes void   ) 
 

Retrieve the number of successful assertions during the last run.

The count is reset each time the client initiates a run.

See also:
CU_get_number_of_failures()

unsigned int CU_get_number_of_suites_failed void   ) 
 

Retrieve the number of suites which failed to initialize during the previous run.

The count is reset each time the client initiates a run.

See also:
CU_get_number_of_tests_run()

unsigned int CU_get_number_of_suites_run void   ) 
 

Retrieve the number of suites completed during the previous run.

The count is reset each time the client initiates a run.

See also:
CU_get_number_of_tests_run()

unsigned int CU_get_number_of_tests_failed void   ) 
 

Retrieve the number of tests which contained failed assertions during the previous run.

The count is reset each time the client initiates a run.

See also:
CU_get_number_of_suites_run()

unsigned int CU_get_number_of_tests_run void   ) 
 

Retrieve the number of tests completed during the previous run.

The count is reset each time the client initiates a run.

See also:
CU_get_number_of_suites_run()

CU_pTestRegistry CU_get_registry void   ) 
 

Retrieve a pointer to the current test registry.

Returns NULL if the registry has not been initialized using CU_initialize_registry. Directly accessing the registry should not be necessary for most users. This function is provided primarily for internal and testing purposes.

Returns:
A pointer to the current registry (NULL if uninitialized).
See also:
CU_initialize_registry

CU_set_registry

CU_pRunSummary CU_get_run_summary void   ) 
 

Retrieve the entire run summary for the last test run.

Note that the pFailure pointer in the run summary is invalidated when the client initiates a run using CU_run_all_tests(), CU_run_suite(), or CU_run_test().

See also:
CU_get_number_of_successes()

CU_pSuite CU_get_suite_by_name const char *  szSuiteName,
CU_pTestRegistry  pRegistry
 

Retrieve a pointer to the suite having the specified name.

Scans the pRegistry and returns a pointer to the first suite located having the specified name.

Parameters:
szSuiteName The name of the suite to locate.
pRegistry The registry to scan.
Returns:
Pointer to the first suite having the specified name, NULL if not found.

CU_SuiteInitFailureMessageHandler CU_get_suite_init_failure_handler void   ) 
 

Retrieve the message handler called when a suite initialization error occurs.

CU_pTest CU_get_test_by_name const char *  szTestName,
CU_pSuite  pSuite
 

Retrieve a pointer to the test case having the specified name.

Scans the pSuite and returns a pointer to the first test case located having the specified name.

Parameters:
szTestName The name of the test case to locate.
pSuite The suite to scan.
Returns:
Pointer to the first test case having the specified name, NULL if not found.

CU_TestCompleteMessageHandler CU_get_test_complete_handler void   ) 
 

Retrieve the message handler called after each test is run.

CU_TestStartMessageHandler CU_get_test_start_handler void   ) 
 

Retrieve the message handler called before each test is run.

CU_ErrorCode CU_initialize_registry void   ) 
 

Initialize the test registry.

Any existing registry is freed, including all stored suites and associated tests. The most recent stored test results are also cleared.

This function must not be called during a test run (checked by assertion).

Returns:
CUE_NOMEMORY if memory for the new registry cannot be allocated, CUE_SUCCESS otherwise.
See also:
CU_cleanup_registry

CU_get_registry

CU_set_registry

BOOL CU_is_test_running void   ) 
 

Returns TRUE if a test run is in progress, TRUE otherwise.

CU_ErrorCode CU_register_nsuites int  suite_count,
  ...
 

Registers multiple suite arrays in CU_SuiteInfo format.

The function accepts a variable number of suite arrays to be registered. The number of arrays is indicated by the value of the 1st argument, suite_count. Each suite in each array is registered with the CUnit test registry, along with all of the associated tests.

Parameters:
suite_count The number of CU_SuiteInfo* arguments to follow.
... suite_count number of CU_SuiteInfo* arguments. NULLs are ignored.
Returns:
A CU_ErrorCode indicating the error status.
See also:
CU_register_suites()

CU_ErrorCode CU_register_suites CU_SuiteInfo  suite_info[]  ) 
 

Registers the suites in a single CU_SuiteInfo array..

Multiple arrays can be registered using CU_register_nsuites().

Parameters:
suite_info NULL-terminated array of CU_SuiteInfo items to register.
Returns:
A CU_ErrorCode indicating the error status.
See also:
CU_register_suites()

CU_ErrorCode CU_run_all_tests void   ) 
 

Run all tests in all suites registered in the test registry.

The suites are run in the order registered in the test registry. For each registered suite, any initialization function is first called, the suite is run using run_single_suite(), and finally any suite cleanup function is called. If an error condition (other than CUE_NOREGISTRY) occurs during the run, the action depends on the current error action (see CU_set_error_action()).

Returns:
A CU_ErrorCode indicating the first error condition encountered while running the tests.
See also:
CU_run_suite() to run the tests in a specific suite.

CU_run_test() for run a specific test only.

CU_ErrorCode CU_run_suite CU_pSuite  pSuite  ) 
 

Run all tests in a specified suite.

The suite need not be registered in the test registry to be run. Any initialization function for the suite is first called, then the suite is run using run_single_suite(), and any suite cleanup function is called. Note that the run statistics (counts of tests, successes, failures) are initialized each time this function is called. If an error condition occurs during the run, the action depends on the current error action (see CU_set_error_action()).

Parameters:
pSuite The suite containing the test (non-NULL)
Returns:
A CU_ErrorCode indicating the first error condition encountered while running the suite. CU_run_suite() sets and returns CUE_NOSUITE if pSuite is NULL. Other error codes can be set during suite initialization or cleanup or during test runs.
See also:
CU_run_all_tests() to run all suites.

CU_run_test() to run a single test in a specific suite.

CU_ErrorCode CU_run_test CU_pSuite  pSuite,
CU_pTest  pTest
 

Run a specific test in a specified suite.

The suite need not be registered in the test registry to be run, although the test must be registered in the specified suite. Any initialization function for the suite is first called, then the test is run using run_single_test(), and any suite cleanup function is called. Note that the run statistics (counts of tests, successes, failures) are initialized each time this function is called.

Parameters:
pSuite The suite containing the test (non-NULL)
pTest The test to run (non-NULL)
Returns:
A CU_ErrorCode indicating the first error condition encountered while running the suite. CU_run_test() sets and returns CUE_NOSUITE if pSuite is NULL, CUE_NOTEST if pTest is NULL, and CUE_TEST_NOT_IN_SUITE if pTest is not registered in pSuite. Other error codes can be set during suite initialization or cleanup or during the test run.
See also:
CU_run_all_tests() to run all tests/suites.

CU_run_suite() to run all tests in a specific suite.

void CU_set_all_test_complete_handler CU_AllTestsCompleteMessageHandler  pAllTestsCompleteHandler  ) 
 

Set the message handler to call after all tests have been run.

void CU_set_error CU_ErrorCode  error  ) 
 

Set the error code.

This function is used internally by CUnit implementation functions when an error condition occurs within the framework. It should not generally be called by user code. NOTE that if the current error action is CUEA_ABORT, then calling this function will result in exit() being called for the current application.

Parameters:
error CU_ErrorCode indicating the current error condition.
See also:
CU_get_error()

CU_get_error_msg()

CU_ErrorCode

void CU_set_error_action CU_ErrorAction  action  ) 
 

Set the action to take when an error condition occurs.

This function should be used to specify the action to take when an error condition is encountered. The default action is CUEA_IGNORE, which results in errors being ignored and test runs being continued (if possible). A value of CUEA_FAIL causes test runs to stop as soon as an error condition occurs, while CU_ABORT causes the application to exit on any error.

Parameters:
action CU_ErrorAction indicating the new error action.
See also:
CU_get_error_action()

CU_set_error()

CU_ErrorAction

CU_pTestRegistry CU_set_registry CU_pTestRegistry  pRegistry  ) 
 

Set the registry to an existing CU_pTestRegistry instance.

A pointer to the original registry is returned. Note that the original registry is not freed, and it becomes the caller's responsibility to do so. Directly accessing the registry should not be necessary for most users. This function is provided primarily for internal and testing purposes.

This function must not be called during a test run (checked by assertion).

Returns:
A pointer to the original registry that was replaced.
See also:
CU_initialize_registry

CU_cleanup_registry

CU_get_registry

void CU_set_suite_init_failure_handler CU_SuiteInitFailureMessageHandler  pSuiteInitFailureHandler  ) 
 

Set the message handler to call when a suite initialization function returns an error.

void CU_set_test_complete_handler CU_TestCompleteMessageHandler  pTestCompleteHandler  ) 
 

Set the message handler to call after each test is run.

void CU_set_test_start_handler CU_TestStartMessageHandler  pTestStartHandler  ) 
 

Set the message handler to call before each test is run.

int CU_translate_special_characters const char *  szSrc,
char *  szDest,
int  maxlen
 

Convert special characters in the specified string to xml entity codes.

The character-entity mappings are contained in the struct bindings. Note that conversion to entities increases the length of the converted string. The worst case conversion would be a string consisting entirely of entity characters of length CUNIT_MAX_ENTITY_LEN. If szDest does not have enough room to convert an entity, it will not be converted. It is the caller's responsibility to make sure there is sufficient room in szDest to hold the converted string.

Parameters:
szSrc Source string to convert (non-NULL).
szDest Location to hold the converted string (non-NULL).
maxlen Maximum number of characters szDest can hold.
Returns:
The number of special characters converted.

Todo:
Consider a function calculating and returning the converted length of a given string.

void CU_trim char *  szString  ) 
 

Trim leading and trailing whitespace from the specified string.

Parameters:
szString The string to trim.

void CU_trim_left char *  szString  ) 
 

Trim leading whitespace from the specified string.

Parameters:
szString The string to trim.

void CU_trim_right char *  szString  ) 
 

Trim trailing whitespace from the specified string.

Parameters:
szString The string to trim.

const char * get_error_desc CU_ErrorCode  iError  )  [static]
 

Internal function to look up the error message for a specified error code.

An empty string is returned if iError is not a member of CU_ErrorCode.

Parameters:
iError CU_ErrorCode to look up.
Returns:
Pointer to a string containing the error message.
See also:
CU_get_error_msg()

int get_index char  ch  )  [static]
 

Check whether a character is a special xml character.

This function performs a lookup of the specified character in the bindings structure. If it is a special character, its index into the bindings array is returned. If not, -1 is returned.

Parameters:
ch The character to check
Returns:
Index into bindings if a special character, -1 otherwise.

void insert_suite CU_pTestRegistry  pRegistry,
CU_pSuite  pSuite
[static]
 

Internal function to insert a suite into a registry.

The suite name is assumed to be unique. Internally, the list of suites is a double-linked list, which this function manages. Insertion of duplicate (or NULL) pSuites is not allowed. Severe problems can occur if this function is called during a test run involving pRegistry.

Parameters:
pRegistry CU_pTestRegistry to insert into (non-NULL).
pSuite CU_pSuite to insert (non-NULL).
See also:
insert_test()

void insert_test CU_pSuite  pSuite,
CU_pTest  pTest
[static]
 

Internal function to insert a test into a suite.

The test name is assumed to be unique. Internally, the list of tests in a suite is a double-linked list, which this function manages. Insertion of duplicate tests (or NULL pTest) is not allowed. Severe problems can occur if this function is called during a test run involving pSuite.

Parameters:
pSuite CU_pSuite to insert into (non-NULL).
pTest CU_pTest to insert (non-NULL).
See also:
insert_suite()

CU_ErrorCode run_single_suite CU_pSuite  pSuite,
CU_pRunSummary  pRunSummary
[static]
 

Run all tests in a specified suite.

Internal function to run all tests in a suite. The suite need not be registered in the test registry to be run. If the CUnit system is in an error condition after running a test, no additional tests are run.

Parameters:
pSuite The suite containing the test (non-NULL).
pRunSummary The CU_RunSummary to receive the results (non-NULL).
Returns:
A CU_ErrorCode indicating the status of the run.
See also:
CU_run_suite() for public interface function.

CU_run_all_tests() for running all suites.

CU_ErrorCode run_single_test CU_pTest  pTest,
CU_pRunSummary  pRunSummary
[static]
 

Run a specific test.

Internal function to run a test case. This includes calling any handler to be run before executing the test, running the test's function (if any), and calling any handler to be run after executing a test.

Parameters:
pTest The test to be run (non-NULL).
pRunSummary The CU_RunSummary to receive the results (non-NULL).
Returns:
A CU_ErrorCode indicating the status of the run.
See also:
CU_run_test() for public interface function.

CU_run_all_tests() for running all suites.

BOOL suite_exists CU_pTestRegistry  pRegistry,
const char *  szSuiteName
[static]
 

Internal function to check whether a suite having a specified name already exists.

Parameters:
pRegistry CU_pTestRegistry to check (non-NULL).
szSuiteName Suite name to check.
Returns:
TRUE if suite exists in the registry, FALSE otherwise.

void test_cunit_activate_malloc void   ) 
 

Enable memory allocation for testing purposes.

void test_cunit_CUError void   ) 
 

void test_cunit_deactivate_malloc void   ) 
 

Disable memory allocation for testing purposes.

unsigned int test_cunit_get_n_allocations void *  pLocation  ) 
 

Retrieve number of allocations for a given pointer.

unsigned int test_cunit_get_n_deallocations void *  pLocation  ) 
 

Retrieve number of deallocations for a given pointer.

unsigned int test_cunit_get_n_memevents void *  pLocation  ) 
 

Retrieve number of memory events for a given pointer.

void test_cunit_MyMem void   ) 
 

The main internal testing function for MyMem.c.

void test_cunit_TestDB void   ) 
 

void test_cunit_TestRun void   ) 
 

void test_cunit_Util void   ) 
 

BOOL test_exists CU_pSuite  pSuite,
const char *  szTestName
[static]
 

Internal function to check whether a test having a specified name is already registered in a given suite.

Parameters:
pSuite CU_pSuite to check.
szTestName Test case name to check.
Returns:
TRUE if test exists in the suite, FALSE otherwise.

int test_suite_register test_suite_t ts  ) 
 

Deprecated (version 1).

Deprecated:
Use CU_SuiteInfo and CU_register_suites().


Variable Documentation

const { ... } bindings [static]
 

Structure containing mappings of special characters to xml entity codes.

BOOL f_bTestIsRunning = FALSE [static]
 

Flag for whether a test run is in progress.

CU_pFailureRecord f_failure_list = NULL [static]
 

CU_pFailureRecord to hold head of failure record list of each test run.

CU_pFailureRecord f_last_failure = NULL [static]
 

Keeps track of end of f_run_summary list for message handlers.

CU_AllTestsCompleteMessageHandler f_pAllTestsCompleteMessageHandler = NULL [static]
 

Pointer to the function to be called when all tests have been run.

CU_pSuite f_pCurSuite = NULL [static]
 

Pointer to the suite currently being run.

CU_pTest f_pCurTest = NULL [static]
 

Pointer to the test currently being run.

CU_SuiteInitFailureMessageHandler f_pSuiteInitFailureMessageHandler = NULL [static]
 

Pointer to the function to be called if a suite initialization function returns an error.

CU_TestCompleteMessageHandler f_pTestCompleteMessageHandler = NULL [static]
 

Pointer to the function to be called after running a test.

CU_pTestRegistry f_pTestRegistry = NULL [static]
 

The active internal Test Registry.

CU_TestStartMessageHandler f_pTestStartMessageHandler = NULL [static]
 

Pointer to the function to be called before running a test.

CU_RunSummary f_run_summary = {0, 0, 0, 0, 0, 0, 0} [static]
 

CU_RunSummary to hold results of each test run.

CU_ErrorCode g_error_action = CUEA_IGNORE [static]
 

Local variable holding the current error action code.

CU_ErrorCode g_error_number = CUE_SUCCESS [static]
 

Local variable holding the current error code.

char* { ... } replacement [inherited]
 

char { ... } special_char [inherited]
 


Generated on Thu Apr 28 12:36:10 2005 for CUnit by  doxygen 1.3.9.1