OpenVPN
|
These headers or their equivalents should be included prior to including this header file. More...
Modules | |
Mock Objects | |
Mock objects mock objects are simulated objects that mimic the behavior of real objects. | |
Checking Parameters | |
Functionality to store expected values for mock function parameters. | |
Assert Macros | |
This is a set of useful assert macros like the standard C libary's assert(3) macro. | |
Call Ordering | |
It is often beneficial to make sure that functions are called in an order. | |
Running Tests | |
This is the way tests are executed with CMocka. | |
Dynamic Memory Allocation | |
Memory leaks, buffer overflows and underflows can be checked using cmocka. | |
Standard Assertions | |
How to handle assert(3) of the standard C library. | |
Data Structures | |
struct | UnitTest |
struct | GroupTest |
struct | CMUnitTest |
struct | SourceLocation |
struct | CheckParameterEvent |
Macros | |
#define | __WORDSIZE 32 |
#define | LargestIntegralType unsigned long long int |
#define | LargestIntegralTypePrintfFormat "0x%I64x" |
#define | cast_to_largest_integral_type(value) ((LargestIntegralType)(value)) |
#define | _UINTPTR_T |
#define | _UINTPTR_T_DEFINED |
#define | cast_to_pointer_integral_type(value) ((uintptr_t)((size_t)(value))) |
#define | cast_ptr_to_largest_integral_type(value) cast_to_largest_integral_type(cast_to_pointer_integral_type(value)) |
#define | CMOCKA_PRINTF_ATTRIBUTE(a, b) |
#define | CMOCKA_DEPRECATED |
Typedefs | |
typedef unsigned int | uintptr_t |
typedef void(* | UnitTestFunction) (void **state) |
typedef int(* | CheckParameterValue) (const LargestIntegralType value, const LargestIntegralType check_value_data) |
typedef enum UnitTestFunctionType | UnitTestFunctionType |
typedef struct UnitTest | UnitTest |
typedef struct GroupTest | GroupTest |
typedef void(* | CMUnitTestFunction) (void **state) |
typedef int(* | CMFixtureFunction) (void **state) |
typedef struct SourceLocation | SourceLocation |
typedef struct CheckParameterEvent | CheckParameterEvent |
Functions | |
LargestIntegralType | _mock (const char *const function, const char *const file, const int line) |
void | _expect_function_call (const char *const function_name, const char *const file, const int line, const int count) |
void | _function_called (const char *const function, const char *const file, const int line) |
void | _expect_check (const char *const function, const char *const parameter, const char *const file, const int line, const CheckParameterValue check_function, const LargestIntegralType check_data, CheckParameterEvent *const event, const int count) |
void | _expect_in_set (const char *const function, const char *const parameter, const char *const file, const int line, const LargestIntegralType values[], const size_t number_of_values, const int count) |
void | _expect_not_in_set (const char *const function, const char *const parameter, const char *const file, const int line, const LargestIntegralType values[], const size_t number_of_values, const int count) |
void | _expect_in_range (const char *const function, const char *const parameter, const char *const file, const int line, const LargestIntegralType minimum, const LargestIntegralType maximum, const int count) |
void | _expect_not_in_range (const char *const function, const char *const parameter, const char *const file, const int line, const LargestIntegralType minimum, const LargestIntegralType maximum, const int count) |
void | _expect_value (const char *const function, const char *const parameter, const char *const file, const int line, const LargestIntegralType value, const int count) |
void | _expect_not_value (const char *const function, const char *const parameter, const char *const file, const int line, const LargestIntegralType value, const int count) |
void | _expect_string (const char *const function, const char *const parameter, const char *const file, const int line, const char *string, const int count) |
void | _expect_not_string (const char *const function, const char *const parameter, const char *const file, const int line, const char *string, const int count) |
void | _expect_memory (const char *const function, const char *const parameter, const char *const file, const int line, const void *const memory, const size_t size, const int count) |
void | _expect_not_memory (const char *const function, const char *const parameter, const char *const file, const int line, const void *const memory, const size_t size, const int count) |
void | _expect_any (const char *const function, const char *const parameter, const char *const file, const int line, const int count) |
void | _check_expected (const char *const function_name, const char *const parameter_name, const char *file, const int line, const LargestIntegralType value) |
void | _will_return (const char *const function_name, const char *const file, const int line, const LargestIntegralType value, const int count) |
void | _assert_true (const LargestIntegralType result, const char *const expression, const char *const file, const int line) |
void | _assert_return_code (const LargestIntegralType result, size_t rlen, const LargestIntegralType error, const char *const expression, const char *const file, const int line) |
void | _assert_int_equal (const LargestIntegralType a, const LargestIntegralType b, const char *const file, const int line) |
void | _assert_int_not_equal (const LargestIntegralType a, const LargestIntegralType b, const char *const file, const int line) |
void | _assert_string_equal (const char *const a, const char *const b, const char *const file, const int line) |
void | _assert_string_not_equal (const char *const a, const char *const b, const char *file, const int line) |
void | _assert_memory_equal (const void *const a, const void *const b, const size_t size, const char *const file, const int line) |
void | _assert_memory_not_equal (const void *const a, const void *const b, const size_t size, const char *const file, const int line) |
void | _assert_in_range (const LargestIntegralType value, const LargestIntegralType minimum, const LargestIntegralType maximum, const char *const file, const int line) |
void | _assert_not_in_range (const LargestIntegralType value, const LargestIntegralType minimum, const LargestIntegralType maximum, const char *const file, const int line) |
void | _assert_in_set (const LargestIntegralType value, const LargestIntegralType values[], const size_t number_of_values, const char *const file, const int line) |
void | _assert_not_in_set (const LargestIntegralType value, const LargestIntegralType values[], const size_t number_of_values, const char *const file, const int line) |
void * | _test_malloc (const size_t size, const char *file, const int line) |
void * | _test_realloc (void *ptr, const size_t size, const char *file, const int line) |
void * | _test_calloc (const size_t number_of_elements, const size_t size, const char *file, const int line) |
void | _test_free (void *const ptr, const char *file, const int line) |
void | _fail (const char *const file, const int line) |
void | _skip (const char *const file, const int line) |
int | _run_test (const char *const function_name, const UnitTestFunction Function, void **const volatile state, const UnitTestFunctionType function_type, const void *const heap_check_point) |
CMOCKA_DEPRECATED int | _run_tests (const UnitTest *const tests, const size_t number_of_tests) |
CMOCKA_DEPRECATED int | _run_group_tests (const UnitTest *const tests, const size_t number_of_tests) |
int | _cmocka_run_group_tests (const char *group_name, const struct CMUnitTest *const tests, const size_t num_tests, CMFixtureFunction group_setup, CMFixtureFunction group_teardown) |
void | print_message (const char *const format,...) CMOCKA_PRINTF_ATTRIBUTE(1 |
void void | print_error (const char *const format,...) CMOCKA_PRINTF_ATTRIBUTE(1 |
void void void | vprint_message (const char *const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1 |
void void void void | vprint_error (const char *const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1 |
void | cmocka_set_message_output (enum cm_message_output output) |
Function to set the output format for a test. More... | |
Variables | |
int | global_expecting_assert |
jmp_buf | global_expect_assert_env |
const char * | global_last_failed_assert |
These headers or their equivalents should be included prior to including this header file.
This allows test applications to use custom definitions of C standard library functions and types.
#define cast_ptr_to_largest_integral_type | ( | value | ) | cast_to_largest_integral_type(cast_to_pointer_integral_type(value)) |
Definition at line 133 of file cmocka.h.
Referenced by _test_free(), free_symbol_map_value(), test_bad_dish(), test_find_operator_function_by_string_found(), test_get_customer_id_by_name(), and test_order_hotdog().
#define cast_to_largest_integral_type | ( | value | ) | ((LargestIntegralType)(value)) |
#define cast_to_pointer_integral_type | ( | value | ) | ((uintptr_t)((size_t)(value))) |
#define CMOCKA_PRINTF_ATTRIBUTE | ( | a, | |
b | |||
) |
Definition at line 141 of file cmocka.h.
Referenced by libc_realloc().
#define LargestIntegralTypePrintfFormat "0x%I64x" |
Definition at line 85 of file cmocka.h.
Referenced by values_equal_display_error(), and values_not_equal_display_error().
typedef struct CheckParameterEvent CheckParameterEvent |
typedef int(* CheckParameterValue) (const LargestIntegralType value, const LargestIntegralType check_value_data) |
typedef struct SourceLocation SourceLocation |
typedef enum UnitTestFunctionType UnitTestFunctionType |
enum cm_message_output |
enum UnitTestFunctionType |
void _assert_in_range | ( | const LargestIntegralType | value, |
const LargestIntegralType | minimum, | ||
const LargestIntegralType | maximum, | ||
const char *const | file, | ||
const int | line | ||
) |
Definition at line 60 of file coverity_assert_model.c.
References _fail(), and integer_in_range_display_error().
void _assert_in_set | ( | const LargestIntegralType | value, |
const LargestIntegralType | values[], | ||
const size_t | number_of_values, | ||
const char *const | file, | ||
const int | line | ||
) |
Definition at line 74 of file coverity_assert_model.c.
References _fail(), CheckIntegerSet::set, CheckIntegerSet::size_of_set, and value_in_set_display_error().
void _assert_int_equal | ( | const LargestIntegralType | a, |
const LargestIntegralType | b, | ||
const char *const | file, | ||
const int | line | ||
) |
Definition at line 10 of file coverity_assert_model.c.
References _fail(), and values_equal_display_error().
void _assert_int_not_equal | ( | const LargestIntegralType | a, |
const LargestIntegralType | b, | ||
const char *const | file, | ||
const int | line | ||
) |
Definition at line 17 of file coverity_assert_model.c.
References _fail(), and values_not_equal_display_error().
void _assert_memory_equal | ( | const void *const | a, |
const void *const | b, | ||
const size_t | size, | ||
const char *const | file, | ||
const int | line | ||
) |
Definition at line 46 of file coverity_assert_model.c.
References _fail(), and memory_equal_display_error().
void _assert_memory_not_equal | ( | const void *const | a, |
const void *const | b, | ||
const size_t | size, | ||
const char *const | file, | ||
const int | line | ||
) |
Definition at line 53 of file coverity_assert_model.c.
References _fail(), and memory_not_equal_display_error().
void _assert_not_in_range | ( | const LargestIntegralType | value, |
const LargestIntegralType | minimum, | ||
const LargestIntegralType | maximum, | ||
const char *const | file, | ||
const int | line | ||
) |
Definition at line 67 of file coverity_assert_model.c.
References _fail(), and integer_not_in_range_display_error().
void _assert_not_in_set | ( | const LargestIntegralType | value, |
const LargestIntegralType | values[], | ||
const size_t | number_of_values, | ||
const char *const | file, | ||
const int | line | ||
) |
Definition at line 81 of file coverity_assert_model.c.
References _fail(), CheckIntegerSet::set, CheckIntegerSet::size_of_set, and value_in_set_display_error().
void _assert_return_code | ( | const LargestIntegralType | result, |
size_t | rlen, | ||
const LargestIntegralType | error, | ||
const char *const | expression, | ||
const char *const | file, | ||
const int | line | ||
) |
Definition at line 24 of file coverity_assert_model.c.
References _fail(), cm_print_error(), LargestIntegralType, and PRIu64.
void _assert_string_equal | ( | const char *const | a, |
const char *const | b, | ||
const char *const | file, | ||
const int | line | ||
) |
Definition at line 34 of file coverity_assert_model.c.
References _fail(), and string_equal_display_error().
void _assert_string_not_equal | ( | const char *const | a, |
const char *const | b, | ||
const char * | file, | ||
const int | line | ||
) |
Definition at line 40 of file coverity_assert_model.c.
References _fail(), and string_not_equal_display_error().
void _assert_true | ( | const LargestIntegralType | result, |
const char *const | expression, | ||
const char *const | file, | ||
const int | line | ||
) |
Definition at line 3 of file coverity_assert_model.c.
References _fail(), and cm_print_error().
Referenced by _test_free().
void _check_expected | ( | const char *const | function_name, |
const char *const | parameter_name, | ||
const char * | file, | ||
const int | line, | ||
const LargestIntegralType | value | ||
) |
Definition at line 1475 of file cmocka.c.
References _fail(), CheckParameterEvent::check_value, CheckParameterEvent::check_value_data, cm_print_error(), exit_test(), free, get_symbol_value(), CheckParameterEvent::location, SOURCE_LOCATION_FORMAT, and source_location_is_set().
int _cmocka_run_group_tests | ( | const char * | group_name, |
const struct CMUnitTest *const | tests, | ||
const size_t | num_tests, | ||
CMFixtureFunction | group_setup, | ||
CMFixtureFunction | group_teardown | ||
) |
Definition at line 2688 of file cmocka.c.
References assert_true, check_point_allocated_blocks(), cm_error_message, CM_TEST_FAILED, CM_TEST_NOT_STARTED, CM_TEST_PASSED, CM_TEST_SKIPPED, cmocka_run_group_fixture(), cmocka_run_one_tests(), cmprintf(), cmprintf_group_finish(), cmprintf_group_start(), discard_const_p, CMUnitTestState::error_message, fail_if_blocks_allocated(), CMUnitTest::initial_state, LargestIntegralType, libc_free(), libc_malloc(), CMUnitTest::name, print_error(), PRINTF_TEST_ERROR, PRINTF_TEST_FAILURE, PRINTF_TEST_SKIPPED, PRINTF_TEST_START, PRINTF_TEST_SUCCESS, CMUnitTestState::runtime, CMUnitTestState::state, CMUnitTestState::status, CMUnitTestState::test, and vcm_free_error().
void _expect_any | ( | const char *const | function, |
const char *const | parameter, | ||
const char *const | file, | ||
const int | line, | ||
const int | count | ||
) |
Definition at line 1467 of file cmocka.c.
References _expect_check(), and check_any().
void _expect_check | ( | const char *const | function, |
const char *const | parameter, | ||
const char *const | file, | ||
const int | line, | ||
const CheckParameterValue | check_function, | ||
const LargestIntegralType | check_data, | ||
CheckParameterEvent *const | event, | ||
const int | count | ||
) |
Definition at line 962 of file cmocka.c.
References add_symbol_value(), CheckParameterEvent::check_value, CheckParameterEvent::check_value_data, CheckParameterEvent::location, malloc, CheckParameterEvent::parameter_name, and set_source_location().
Referenced by _expect_any(), _expect_not_string(), _expect_not_value(), _expect_string(), _expect_value(), expect_memory_setup(), expect_range(), and expect_set().
void _expect_function_call | ( | const char *const | function_name, |
const char *const | file, | ||
const int | line, | ||
const int | count | ||
) |
Definition at line 985 of file cmocka.c.
References assert_non_null, assert_true, FuncOrderingValue::function, list_add_value(), FuncOrderingValue::location, malloc, and set_source_location().
void _expect_in_range | ( | const char *const | function, |
const char *const | parameter, | ||
const char *const | file, | ||
const int | line, | ||
const LargestIntegralType | minimum, | ||
const LargestIntegralType | maximum, | ||
const int | count | ||
) |
Definition at line 1290 of file cmocka.c.
References check_in_range(), and expect_range().
void _expect_in_set | ( | const char *const | function, |
const char *const | parameter, | ||
const char *const | file, | ||
const int | line, | ||
const LargestIntegralType | values[], | ||
const size_t | number_of_values, | ||
const int | count | ||
) |
Definition at line 1227 of file cmocka.c.
References check_in_set(), and expect_set().
void _expect_memory | ( | const char *const | function, |
const char *const | parameter, | ||
const char *const | file, | ||
const int | line, | ||
const void *const | memory, | ||
const size_t | size, | ||
const int | count | ||
) |
Definition at line 1424 of file cmocka.c.
References check_memory(), and expect_memory_setup().
void _expect_not_in_range | ( | const char *const | function, |
const char *const | parameter, | ||
const char *const | file, | ||
const int | line, | ||
const LargestIntegralType | minimum, | ||
const LargestIntegralType | maximum, | ||
const int | count | ||
) |
Definition at line 1301 of file cmocka.c.
References check_not_in_range(), and expect_range().
void _expect_not_in_set | ( | const char *const | function, |
const char *const | parameter, | ||
const char *const | file, | ||
const int | line, | ||
const LargestIntegralType | values[], | ||
const size_t | number_of_values, | ||
const int | count | ||
) |
Definition at line 1238 of file cmocka.c.
References check_not_in_set(), and expect_set().
void _expect_not_memory | ( | const char *const | function, |
const char *const | parameter, | ||
const char *const | file, | ||
const int | line, | ||
const void *const | memory, | ||
const size_t | size, | ||
const int | count | ||
) |
Definition at line 1448 of file cmocka.c.
References check_not_memory(), and expect_memory_setup().
void _expect_not_string | ( | const char *const | function, |
const char *const | parameter, | ||
const char *const | file, | ||
const int | line, | ||
const char * | string, | ||
const int | count | ||
) |
Definition at line 1379 of file cmocka.c.
References _expect_check(), check_not_string(), declare_initialize_value_pointer_pointer, and discard_const.
void _expect_not_value | ( | const char *const | function, |
const char *const | parameter, | ||
const char *const | file, | ||
const int | line, | ||
const LargestIntegralType | value, | ||
const int | count | ||
) |
Definition at line 1338 of file cmocka.c.
References _expect_check(), and check_not_value().
void _expect_string | ( | const char *const | function, |
const char *const | parameter, | ||
const char *const | file, | ||
const int | line, | ||
const char * | string, | ||
const int | count | ||
) |
Definition at line 1357 of file cmocka.c.
References _expect_check(), check_string(), declare_initialize_value_pointer_pointer, and discard_const.
void _expect_value | ( | const char *const | function, |
const char *const | parameter, | ||
const char *const | file, | ||
const int | line, | ||
const LargestIntegralType | value, | ||
const int | count | ||
) |
Definition at line 1320 of file cmocka.c.
References _expect_check(), and check_value().
void _fail | ( | const char *const | file, |
const int | line | ||
) |
Definition at line 1956 of file cmocka.c.
References cm_get_output(), CM_OUTPUT_STDOUT, cm_print_error(), exit_test(), and SOURCE_LOCATION_FORMAT.
Referenced by _assert_in_range(), _assert_in_set(), _assert_int_equal(), _assert_int_not_equal(), _assert_memory_equal(), _assert_memory_not_equal(), _assert_not_in_range(), _assert_not_in_set(), _assert_return_code(), _assert_string_equal(), _assert_string_not_equal(), _assert_true(), _check_expected(), _test_free(), and mock_assert().
void _function_called | ( | const char *const | function, |
const char *const | file, | ||
const int | line | ||
) |
Definition at line 868 of file cmocka.c.
References cm_print_error(), exit_test(), free_value(), FuncOrderingValue::function, list_first(), list_remove_free(), ListNode::next, ListNode::prev, ListNode::refcount, SOURCE_LOCATION_FORMAT, and ListNode::value.
LargestIntegralType _mock | ( | const char *const | function, |
const char *const | file, | ||
const int | line | ||
) |
Definition at line 837 of file cmocka.c.
References cm_print_error(), exit_test(), free, get_symbol_value(), LargestIntegralType, SymbolValue::location, SOURCE_LOCATION_FORMAT, source_location_is_set(), ValuePointer::value, and SymbolValue::value.
CMOCKA_DEPRECATED int _run_group_tests | ( | const UnitTest *const | tests, |
const size_t | number_of_tests | ||
) |
Definition at line 3082 of file cmocka.c.
References _run_test(), TestState::check_point, CMUnitTestState::check_point, check_point_allocated_blocks(), exit_test(), fail_if_blocks_allocated(), free, UnitTest::function, UnitTest::function_type, malloc, UnitTest::name, PRIdS, print_error(), print_message(), run_test, setup(), TestState::state, teardown(), CMUnitTestState::test, UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP, UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN, UNIT_TEST_FUNCTION_TYPE_SETUP, UNIT_TEST_FUNCTION_TYPE_TEARDOWN, and UNIT_TEST_FUNCTION_TYPE_TEST.
int _run_test | ( | const char *const | function_name, |
const UnitTestFunction | Function, | ||
void **const volatile | state, | ||
const UnitTestFunctionType | function_type, | ||
const void *const | heap_check_point | ||
) |
Definition at line 2850 of file cmocka.c.
References ARRAY_SIZE, CMUnitTestState::check_point, check_point_allocated_blocks(), cm_error_message_enabled, cm_setjmp, exception_filter(), fail_if_blocks_allocated(), fail_if_leftover_values(), initialize_testing(), IsDebuggerPresent(), print_message(), teardown_testing(), UNIT_TEST_FUNCTION_TYPE_SETUP, and UNIT_TEST_FUNCTION_TYPE_TEST.
Referenced by _run_group_tests(), and _run_tests().
CMOCKA_DEPRECATED int _run_tests | ( | const UnitTest *const | tests, |
const size_t | number_of_tests | ||
) |
Definition at line 2927 of file cmocka.c.
References _run_test(), assert_null, assert_true, TestState::check_point, CMUnitTestState::check_point, check_point_allocated_blocks(), exit_test(), fail_if_blocks_allocated(), free, UnitTest::function, UnitTest::function_type, LargestIntegralType, malloc, UnitTest::name, PRIdS, print_error(), print_message(), TestState::state, CMUnitTestState::test, UNIT_TEST_FUNCTION_TYPE_SETUP, UNIT_TEST_FUNCTION_TYPE_TEARDOWN, and UNIT_TEST_FUNCTION_TYPE_TEST.
void _skip | ( | const char *const | file, |
const int | line | ||
) |
Definition at line 392 of file cmocka.c.
References cm_print_error(), exit_test(), and SOURCE_LOCATION_FORMAT.
void* _test_calloc | ( | const size_t | number_of_elements, |
const size_t | size, | ||
const char * | file, | ||
const int | line | ||
) |
Definition at line 1798 of file cmocka.c.
References _test_malloc().
void _test_free | ( | void *const | ptr, |
const char * | file, | ||
const int | line | ||
) |
Definition at line 1810 of file cmocka.c.
References _assert_true(), _fail(), MallocBlockInfo::allocated_size, ARRAY_SIZE, MallocBlockInfo::block, cast_ptr_to_largest_integral_type, cm_print_error(), discard_const_p, SourceLocation::file, free, SourceLocation::line, list_remove(), MallocBlockInfo::location, MALLOC_FREE_PATTERN, MALLOC_GUARD_PATTERN, MALLOC_GUARD_SIZE, MallocBlockInfo::node, MallocBlockInfo::size, and SOURCE_LOCATION_FORMAT.
Referenced by _test_realloc().
void* _test_malloc | ( | const size_t | size, |
const char * | file, | ||
const int | line | ||
) |
Definition at line 1767 of file cmocka.c.
References MallocBlockInfo::allocated_size, assert_non_null, MallocBlockInfo::block, get_allocated_blocks_list(), list_add(), MallocBlockInfo::location, malloc, MALLOC_ALIGNMENT, MALLOC_ALLOC_PATTERN, MALLOC_GUARD_PATTERN, MALLOC_GUARD_SIZE, MallocBlockInfo::node, set_source_location(), MallocBlockInfo::size, and ListNode::value.
Referenced by _test_calloc(), and _test_realloc().
void* _test_realloc | ( | void * | ptr, |
const size_t | size, | ||
const char * | file, | ||
const int | line | ||
) |
Definition at line 1853 of file cmocka.c.
References _test_free(), _test_malloc(), MALLOC_GUARD_SIZE, and MallocBlockInfo::size.
void _will_return | ( | const char *const | function_name, |
const char *const | file, | ||
const int | line, | ||
const LargestIntegralType | value, | ||
const int | count | ||
) |
Definition at line 943 of file cmocka.c.
References add_symbol_value(), assert_true, SymbolValue::location, malloc, set_source_location(), ValuePointer::value, and SymbolValue::value.
void cmocka_set_message_output | ( | enum cm_message_output | output | ) |
Function to set the output format for a test.
The ouput format for the test can either be set globally using this function or overriden with environment variable CMOCKA_MESSAGE_OUTPUT.
The environment variable can be set to either STDOUT, SUBUNIT, TAP or XML.
[in] | output | The output format to use for the test. |
Definition at line 2431 of file cmocka.c.
References global_msg_output.
void void print_error | ( | const char *const | format, |
... | |||
) |
void print_message | ( | const char *const | format, |
... | |||
) |
void void void void vprint_error | ( | const char *const | format, |
va_list | args | ||
) |
void void void vprint_message | ( | const char *const | format, |
va_list | args | ||
) |
const char* global_last_failed_assert |
Definition at line 279 of file cmocka.c.
Referenced by mock_assert().