Struct MutinyMockSupport¶
Defined in File mock.h
Struct Documentation¶
-
struct MutinyMockSupport¶
[source] Vtable for the global or named mock support scope (C interface).
Obtained by calling mutiny_mock() or mutiny_mock_scope(). Use the function pointers to set up expectations, report actual calls, install comparators, and verify/clear state.
See also
Public Members
-
void (*strict_order)(void)¶
Require calls to arrive in registration order.
-
struct MutinyMockExpectedCall *(*expect_one_call)(const char *name)¶
Expect exactly one call.
- Param name:
Function name.
- Return:
Expected-call vtable.
-
void (*expect_no_call)(const char *name)¶
Assert function is never called.
- Param name:
Function name.
-
struct MutinyMockExpectedCall *(*expect_n_calls)(unsigned int number, const char *name)¶
Expect exactly
numbercalls.- Param number:
Count.
- Param name:
Function name.
- Return:
Expected-call vtable.
-
struct MutinyMockActualCall *(*actual_call)(const char *name)¶
Report an actual call from a mock implementation.
- Param name:
Function name.
- Return:
Actual-call vtable.
-
int (*has_return_value)(void)¶
- Return:
Non-zero if the last actual call has a configured return value.
-
struct MutinyMockValue (*return_value)(void)¶
- Return:
The last actual call’s return value as a tagged union.
-
int (*bool_return_value)(void)¶
- Return:
The configured bool return value (as
int).
-
int (*return_bool_value_or_default)(int default_value)¶
- Param default_value:
Fallback.
- Return:
Bool return value or
default_value.
-
int (*int_return_value)(void)¶
- Return:
The configured int return value.
-
int (*return_int_value_or_default)(int default_value)¶
- Param default_value:
Fallback.
- Return:
Int return value or
default_value.
-
unsigned int (*unsigned_int_return_value)(void)¶
- Return:
The configured
unsigned intreturn value.
-
unsigned int (*return_unsigned_int_value_or_default)(unsigned int default_value)¶
- Param default_value:
Fallback.
- Return:
Unsigned int return value or
default_value.
-
long int (*long_int_return_value)(void)¶
- Return:
The configured
long intreturn value.
-
long int (*return_long_int_value_or_default)(long int default_value)¶
- Param default_value:
Fallback.
- Return:
Long int return value or
default_value.
-
unsigned long int (*unsigned_long_int_return_value)(void)¶
- Return:
The configured
unsigned long intreturn value.
-
unsigned long int (*return_unsigned_long_int_value_or_default)(unsigned long int default_value)¶
- Param default_value:
Fallback.
- Return:
unsigned long intreturn value ordefault_value.
-
long long (*long_long_int_return_value)(void)¶
- Return:
The configured
long longreturn value.
-
long long (*return_long_long_int_value_or_default)(long long default_value)¶
- Param default_value:
Fallback.
- Return:
long longreturn value ordefault_value.
-
unsigned long long (*unsigned_long_long_int_return_value)(void)¶
- Return:
The configured
unsigned long longreturn value.
-
unsigned long long (*return_unsigned_long_long_int_value_or_default)(unsigned long long default_value)¶
- Param default_value:
Fallback.
- Return:
unsigned long longreturn value ordefault_value.
-
const char *(*string_return_value)(void)¶
- Return:
The configured C string return value.
-
const char *(*return_string_value_or_default)(const char *default_value)¶
- Param default_value:
Fallback.
- Return:
String return value or
default_value.
-
double (*double_return_value)(void)¶
- Return:
The configured
doublereturn value.
-
double (*return_double_value_or_default)(double default_value)¶
- Param default_value:
Fallback.
- Return:
doublereturn value ordefault_value.
-
void *(*pointer_return_value)(void)¶
- Return:
The configured
void*return value.
-
void *(*return_pointer_value_or_default)(void *default_value)¶
- Param default_value:
Fallback.
- Return:
Pointer return value or
default_value.
-
const void *(*const_pointer_return_value)(void)¶
- Return:
The configured
const void*return value.
-
const void *(*return_const_pointer_value_or_default)(const void *default_value)¶
- Param default_value:
Fallback.
- Return:
constpointer return value ordefault_value.
-
void (*(*function_pointer_return_value)(void))(void)¶
- Return:
The configured function pointer return value.
-
void (*(*return_function_pointer_value_or_default)(void (*default_value)(void)))(void)¶
- Param default_value:
Fallback.
- Return:
Function pointer return value or
default_value.
-
void (*set_bool_data)(const char *name, int value)¶
Store a bool data value.
- Param name:
Key.
- Param value:
Value.
-
void (*set_int_data)(const char *name, int value)¶
Store an int data value.
- Param name:
Key.
- Param value:
Value.
-
void (*set_unsigned_int_data)(const char *name, unsigned int value)¶
Store an
unsigned intdata value.- Param name:
Key.
- Param value:
Value.
-
void (*set_long_int_data)(const char *name, long int value)¶
Store a long int data value.
- Param name:
Key.
- Param value:
Value.
-
void (*set_unsigned_long_int_data)(const char *name, unsigned long int value)¶
Store an
unsigned long intdata value.- Param name:
Key.
- Param value:
Value.
-
void (*set_long_long_int_data)(const char *name, long long value)¶
Store a
long long intdata value.- Param name:
Key.
- Param value:
Value.
-
void (*set_unsigned_long_long_int_data)(const char *name, unsigned long long value)¶
Store an
unsigned long long intdata value.- Param name:
Key.
- Param value:
Value.
-
void (*set_string_data)(const char *name, const char *value)¶
Store a string data value.
- Param name:
Key.
- Param value:
Value.
-
void (*set_double_data)(const char *name, double value)¶
Store a
doubledata value.- Param name:
Key.
- Param value:
Value.
-
void (*set_pointer_data)(const char *name, void *value)¶
Store a
void*data value.- Param name:
Key.
- Param value:
Value.
-
void (*set_const_pointer_data)(const char *name, const void *value)¶
Store a
const void*data value.- Param name:
Key.
- Param value:
Value.
-
void (*set_function_pointer_data)(const char *name, void (*value)(void))¶
Store a function pointer data value.
- Param name:
Key.
- Param value:
Value.
-
void (*set_data_object)(const char *name, const char *type, void *value)¶
Store a mutable object pointer with type name.
- Param name:
Key.
- Param type:
Type name.
- Param value:
Object pointer.
-
void (*set_data_const_object)(const char *name, const char *type, const void *value)¶
Store a
constobject pointer with type name.- Param name:
Key.
- Param type:
Type name.
- Param value:
Object pointer.
-
struct MutinyMockValue (*get_data)(const char *name)¶
- Param name:
Key.
- Return:
Previously stored data value.
-
void (*disable)(void)¶
Disable this scope; actual_call() becomes a no-op.
-
void (*ignore_other_calls)(void)¶
Suppress unexpected-call failures.
All actual_call() invocations are silently accepted without matching an expectation.
-
void (*check_expectations)(void)¶
Verify all expected calls were fulfilled; fail the test if not.
Typically called at the end of each test.
-
int (*expected_calls_left)(void)¶
- Return:
Non-zero if there are unfulfilled expectations remaining.
-
void (*clear)(void)¶
Remove all expectations, actual calls, and data.
Call after check_expectations() to leave a clean state.
-
void (*crash_on_failure)(unsigned should_crash)¶
Choose whether mock failures crash the process.
- Param should_crash:
Non-zero to crash on failure (useful with a debugger).
-
void (*install_comparator)(const char *type_name, MutinyMockTypeEqualFunction is_equal, MutinyMockTypeValueToStringFunction value_to_string)¶
Register a C comparator for objects of type
type_name.- Param type_name:
Type name key.
- Param is_equal:
Equality predicate function.
- Param value_to_string:
String-conversion function.
-
void (*install_copier)(const char *type_name, MutinyMockTypeCopyFunction copier)¶
Register a C copier for objects of type
type_name.- Param type_name:
Type name key.
- Param copier:
Copy function.
-
void (*remove_all_comparators_and_copiers)(void)¶
Remove all installed comparators and copiers from this scope.
-
void (*strict_order)(void)¶