|
cmocka 2.0.0
Unit testing library with mock support
|
Simulate objects and control function return values in tests. More...
Macros | |
| #define | WILL_RETURN_ALWAYS -1 |
| Return a value indefinitely when used with will_return_count(). | |
| #define | WILL_RETURN_ONCE -2 |
| Return a value once when used with will_return_count(). | |
| #define | EXPECT_ALWAYS -1 |
| Check a parameter every time when used with expect_check_data_count(). | |
| #define | EXPECT_MAYBE -2 |
| Optionally check a parameter when used with expect_check_data_count(). | |
Functions | |
| uintmax_t | mock (void) |
| Retrieve a return value of the current function. | |
| type | mock_type (#type) |
| Retrieve a value of the current function and cast it to given type. | |
| bool | has_mock (void) |
| Check if data is available for the current mock function. | |
| intmax_t | mock_int () |
| Retrieve an integer return value of the current function. | |
| uintmax_t | mock_uint (void) |
| Retrieve an unsigned integer return value of the current function. | |
| float | mock_float (void) |
| Retrieve a float return value of the current function. | |
| double | mock_double (void) |
| Retrieve a double precision floating point return value of the current function. | |
| type | mock_ptr_type (#type) |
| Retrieve a typed return value of the current function. | |
| type | mock_ptr_type_checked (#type) |
| Retrieve a typed return value of the current function with type checking. | |
| uintmax_t | mock_parameter (#name) |
| Retrieve a named value for the current function. | |
| intmax_t | mock_parameter_int (#name) |
| Retrieve a named value for the current function and cast it to given type. | |
| uintmax_t | mock_parameter_uint (#name) |
| Retrieve an unsigned integer return value of the current function. | |
| float | mock_parameter_float (#name) |
| Retrieve a named float value for the current function. | |
| double | mock_parameter_double (#name) |
| Retrieve a named double precision floating point value for the current function. | |
| void * | mock_parameter_ptr (#name) |
| Retrieve a named pointer for the current function. | |
| type | mock_parameter_ptr_type (#name, #type) |
| Retrieve a named pointer for the current function. | |
| void | mock_errno (void) |
| set errno for the current function. | |
| void | will_return (#function, uintmax_t value) |
| Store a value to be returned by mock() later. | |
| void | will_return_int (#function, intmax_t value) |
| Store an integer value to be returned by mock() later. | |
| void | will_return_int_count (#function, intmax_t value, int count) |
| Store an integer value to be returned a specified number of times by mock() later. | |
| void | will_return_uint (#function, uintmax_t value) |
| Store a unsigned integer value to be returned by mock() later. | |
| void | will_return_uint_count (#function, uintmax_t value, int count) |
| Store an unsigned integer value to be returned a specified number of times by mock() later. | |
| void | will_return_float (#function, float value) |
| Store a float value to be returned by mock() later. | |
| void | will_return_float_count (#function, float value, int count) |
| Store a float value to be returned a specified number of times by mock() later. | |
| void | will_return_double (#function, double value) |
| Store a double precision floating point value to be returned by mock() later. | |
| void | will_return_double_count (#function, double value, int count) |
| Store a double precision floating point value to be returned a specified number of times by mock() later. | |
| void | will_return_int_always (#function, intmax_t value) |
| Store an integer value that will always be returned by mock_int(). | |
| void | will_return_uint_always (#function, uintmax_t value) |
| Store an unsigned integer value that will always be returned by mock_uint(). | |
| void | will_return_float_always (#function, float value) |
| Store a float value that will always be returned by mock_float(). | |
| void | will_return_double_always (#function, double value) |
| Store a double value that will always be returned by mock_double(). | |
| void | will_return_count (#function, uintmax_t value, int count) |
| void | will_return_always (#function, uintmax_t value) |
| void | will_return_int_maybe (#function, intmax_t value) |
| Store an integer value that may always be returned by mock_int(). | |
| void | will_return_uint_maybe (#function, uintmax_t value) |
| Store an unsigned integer value that may always be returned by mock_uint(). | |
| void | will_return_float_maybe (#function, float value) |
| Store a float value that may always be returned by mock_float(). | |
| void | will_return_double_maybe (#function, double value) |
| Store a double value that may always be returned by mock_double(). | |
| void | will_return_maybe (#function, uintmax_t value) |
| void | will_return_ptr (#function, void *value) |
| Store a pointer value to be returned by mock_ptr_type() later. | |
| void | will_return_ptr_type (#function, void *value, type) |
| Store a pointer value to be returned by mock_ptr_type_checked() later. | |
| void | will_return_ptr_count (#function, void *value, int count) |
| Store a pointer value to be returned by mock_ptr_type() later. | |
| void | will_return_ptr_always (#function, void *value) |
| Store a value that will be always returned by mock_ptr_type(). | |
| void | will_return_ptr_maybe (#function, void *value) |
| Store a value that may be always returned by mock_ptr_type(). | |
| void | will_set_parameter (#function, #name, uintmax_t value) |
| Store a named value to be returned by mock_parameter() later. | |
| void | will_set_parameter_int (#function, #name, intmax_t value) |
| Store a named integer value to be returned by mock_parameter() later. | |
| void | will_set_parameter_uint (#function, #name, uintmax_t value) |
| Store a named unsigned integer value to be returned by mock_parameter() later. | |
| void | will_set_parameter_float (#function, #name, float value) |
| Store a named float value to be returned by mock_parameter() later. | |
| void | will_set_parameter_double (#function, #name, double value) |
| Store a named double precision floating point value to be returned by mock_parameter() later. | |
| void | will_set_parameter_int_count (#function, #name, intmax_t value, int count) |
| Store a named integer value to be returned a specified number of times by mock_parameter_int() later. | |
| void | will_set_parameter_uint_count (#function, uintmax_t value, int count) |
| Store a named unsigned integer value to be returned a specified number of times by mock_parameter_uint() later. | |
| void | will_set_parameter_float_count (#function, #name, float value, int count) |
| Store a named float value to be returned a specified number of times by mock_parameter_float() later. | |
| void | will_set_parameter_double_count (#function, #name, double value, int count) |
| Store a named double value to be returned a specified number of times by mock_parameter_double() later. | |
| void | will_set_parameter_count (#function, #name, uintmax_t value, int count) |
| void | will_set_parameter_int_always (#function, #name, intmax_t value) |
| Store a named integer value that will always be returned by mock_parameter_int(). | |
| void | will_set_parameter_uint_always (#function, #name, uintmax_t value) |
| Store a named unsigned integer value that will always be returned by mock_parameter_uint(). | |
| void | will_set_parameter_float_always (#function, #name, float value) |
| Store a named float value that will always be returned by mock_parameter_float(). | |
| void | will_set_parameter_double_always (#function, #name, double value) |
| Store a named double value that will always be returned by mock_parameter_double(). | |
| void | will_set_parameter_always (#function, #name, uintmax_t value) |
| void | will_set_parameter_int_maybe (#function, #name, intmax_t value) |
| Store a named integer value that may always be returned by mock_parameter_int(). | |
| void | will_set_parameter_uint_maybe (#function, #name, uintmax_t value) |
| Store a named unsigned integer value that may always be returned by mock_parameter_uint(). | |
| void | will_set_parameter_float_maybe (#function, #name, float value) |
| Store a named float value that may always be returned by mock_parameter_float(). | |
| void | will_set_parameter_double_maybe (#function, #name, double value) |
| Store a named double value that may always be returned by mock_parameter_double(). | |
| void | will_set_parameter_maybe (#function, #name, uintmax_t value) |
| void | will_set_parameter_ptr (#function, #name, void *value) |
| Store a named pointer value to be returned by mock_parameter() later. | |
| void | will_set_parameter_ptr_type (#function, #name, void *value, #type) |
| Store a named pointer value to be returned by mock_parameter() later. | |
| void | will_set_parameter_ptr_count (#function, #name, void *value, int count) |
| Store a named pointer value to be returned a specified number of times by mock_parameter_ptr() later. | |
| void | will_set_parameter_ptr_always (#function, #name, void *value) |
| Store a named pointer value that will be always returned by mock_parameter_ptr(). | |
| void | will_set_parameter_ptr_maybe (#function, #name, void *value) |
| Store a named pointer value that may be always returned by mock_parameter_ptr(). | |
| void | will_set_errno (#function, intmax_t value) |
| Store an integer value to set errno to by mock_errno() later. | |
| void | will_set_errno_count (#function, intmax_t value, size_t count) |
| Store an integer value to always set errno to by mock_errno(). | |
| void | will_set_errno_always (#function, intmax_t value) |
| Store an integer value to set errno to by mock_errno() later, for a specified number of times. | |
| void | will_set_errno_maybe (#function, intmax_t value) |
| Store an integer value to set errno to by mock_errno() later, for a specified number of times. | |
Simulate objects and control function return values in tests.
Mock objects are simulated objects that mimic the behavior of real objects. Instead of calling the real objects, the tested object calls a mock object that merely asserts that the correct methods were called, with the expected parameters, in the correct order.
will_return(function, value) - The will_return() macro pushes a value onto a queue of mock values. This macro is intended to be used by the unit test itself, while programming the behaviour of the mocked object.
Because the will_return() and mock() are intended to be used in pairs, the cmocka library would fail the test if there are more values pushed onto the queue using will_return() than consumed with mock() and vice-versa.
The following unit test stub illustrates how would a unit test instruct the mock object to return a particular value:
Now the mock object can check if the parameter it received is the parameter which is expected by the test driver. This can be done the following way:
For a complete example please take a look here.
| #define EXPECT_ALWAYS -1 |
Check a parameter every time when used with expect_check_data_count().
This constant can be passed as the count parameter to expect_check_data_count() to indicate that the parameter check should be performed every time the mocked function is called. The test will fail if the function is never called.
| #define EXPECT_MAYBE -2 |
Optionally check a parameter when used with expect_check_data_count().
This constant can be passed as the count parameter to expect_check_data_count() to indicate that the parameter check is optional. The check will be performed if the function is called, but the test will not fail if it's never called.
| #define WILL_RETURN_ALWAYS -1 |
Return a value indefinitely when used with will_return_count().
This constant can be passed as the count parameter to will_return_count() and related functions to indicate that the specified value should be returned every time the mocked function is called, without limit.
| #define WILL_RETURN_ONCE -2 |
Return a value once when used with will_return_count().
This constant can be passed as the count parameter to will_return_count() and related functions to indicate that the specified value should be returned only the next time the mocked function is called. This is the default behavior of will_return() and related macros.
| bool has_mock | ( | void | ) |
Check if data is available for the current mock function.
This function checks if there is data available for the current mock function which calls has_mock() without consuming it. This is useful when you want to check if mock data has been set up before calling mock().
| uintmax_t mock | ( | void | ) |
Retrieve a return value of the current function.
| double mock_double | ( | void | ) |
Retrieve a double precision floating point return value of the current function.
| void mock_errno | ( | void | ) |
set errno for the current function.
| float mock_float | ( | void | ) |
Retrieve a float return value of the current function.
| intmax_t mock_int | ( | ) |
Retrieve an integer return value of the current function.
| uintmax_t mock_parameter | ( | # | name | ) |
Retrieve a named value for the current function.
| [in] | name | The name under which to look for the value |
| double mock_parameter_double | ( | # | name | ) |
Retrieve a named double precision floating point value for the current function.
| [in] | name | The name under which to look for the value |
| float mock_parameter_float | ( | # | name | ) |
Retrieve a named float value for the current function.
| [in] | name | The name under which to look for the value |
| intmax_t mock_parameter_int | ( | # | name | ) |
Retrieve a named value for the current function and cast it to given type.
The value would be casted to type internally to avoid having the caller to do the cast manually. Type safety checks are disabled with that function.
| [in] | name | The name under which to look for the value | |
| [in] | type | The expected type of the named value |
Retrieve a named integer value for the current function.
| [in] | name | The name under which to look for the value |
| void * mock_parameter_ptr | ( | # | name | ) |
Retrieve a named pointer for the current function.
| [in] | name | The name under which to look for the pointer |
| type mock_parameter_ptr_type | ( | # | name, |
| # | type ) |
Retrieve a named pointer for the current function.
In addition it checks if if the type specified by the call to will_return_ptr_type() is the same. And casts it to that type.
| [in] | name | The name under which to look for the pointer |
| uintmax_t mock_parameter_uint | ( | # | name | ) |
Retrieve an unsigned integer return value of the current function.
| [in] | name | The name under which to look for the value |
| type mock_ptr_type | ( | # | type | ) |
Retrieve a typed return value of the current function.
The value would be casted to type internally to avoid having the caller to do the cast manually. This macro does NOT perform type checking. For type-safe pointer retrieval, use mock_ptr_type_checked() instead.
| [in] | type | The expected type of the return value |
| type mock_ptr_type_checked | ( | # | type | ) |
Retrieve a typed return value of the current function with type checking.
The value would be casted to type internally to avoid having the caller to do the cast manually. This macro DOES perform type checking and will fail the test if the type used with will_return_ptr_type() does not match the type passed to this macro.
| [in] | type | The expected type of the return value |
| type mock_type | ( | # | type | ) |
Retrieve a value of the current function and cast it to given type.
The value would be casted to type internally to avoid having the caller to do the cast manually. Type safety checks are disabled with that function.
| [in] | type | The expected type of the return value |
| uintmax_t mock_uint | ( | void | ) |
Retrieve an unsigned integer return value of the current function.
| void will_return | ( | # | function, |
| uintmax_t | value ) |
Store a value to be returned by mock() later.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock(). |
| void will_return_always | ( | # | function, |
| uintmax_t | value ) |
| void will_return_count | ( | # | function, |
| uintmax_t | value, | ||
| int | count ) |
| void will_return_double | ( | # | function, |
| double | value ) |
Store a double precision floating point value to be returned by mock() later.
| [in] | function | The function which should return the given value. | |
| [in] | value | The double value to be returned by mock(). |
| void will_return_double_always | ( | # | function, |
| double | value ) |
Store a double value that will always be returned by mock_double().
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_double(). |
This is equivalent to:
| void will_return_double_count | ( | # | function, |
| double | value, | ||
| int | count ) |
Store a double precision floating point value to be returned a specified number of times by mock() later.
| [in] | function | The function which should return the given value. | |
| [in] | value | The double value to be returned by mock(). | |
| [in] | count | The parameter indicates the number of times the value should be returned by mock_double(). If count is set to -1, the value will always be returned but must be returned at least once. If count is set to -2, the value will always be returned by mock_double(), but is not required to be returned. |
| void will_return_double_maybe | ( | # | function, |
| double | value ) |
Store a double value that may always be returned by mock_double().
This stores a value which will always be returned by mock_double() but is not required to be returned by at least one call to mock_double(). Therefore, in contrast to will_return_double_always() which causes a test failure if it is not returned at least once, will_return_double_maybe() will never cause a test to fail if its value is not returned.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_double(). |
This is equivalent to:
| void will_return_float | ( | # | function, |
| float | value ) |
Store a float value to be returned by mock() later.
| [in] | function | The function which should return the given value. | |
| [in] | value | The float value to be returned by mock(). |
| void will_return_float_always | ( | # | function, |
| float | value ) |
Store a float value that will always be returned by mock_float().
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_float(). |
This is equivalent to:
| void will_return_float_count | ( | # | function, |
| float | value, | ||
| int | count ) |
Store a float value to be returned a specified number of times by mock() later.
| [in] | function | The function which should return the given value. | |
| [in] | value | The float value to be returned by mock(). | |
| [in] | count | The parameter indicates the number of times the value should be returned by mock_float(). If count is set to -1, the value will always be returned but must be returned at least once. If count is set to -2, the value will always be returned by mock_float(), but is not required to be returned. |
| void will_return_float_maybe | ( | # | function, |
| float | value ) |
Store a float value that may always be returned by mock_float().
This stores a value which will always be returned by mock_float() but is not required to be returned by at least one call to mock_float(). Therefore, in contrast to will_return_float_always() which causes a test failure if it is not returned at least once, will_return_float_maybe() will never cause a test to fail if its value is not returned.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_float(). |
This is equivalent to:
| void will_return_int | ( | # | function, |
| intmax_t | value ) |
Store an integer value to be returned by mock() later.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock(). |
| void will_return_int_always | ( | # | function, |
| intmax_t | value ) |
Store an integer value that will always be returned by mock_int().
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_int(). |
This is equivalent to:
| void will_return_int_count | ( | # | function, |
| intmax_t | value, | ||
| int | count ) |
Store an integer value to be returned a specified number of times by mock() later.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock(). | |
| [in] | count | The parameter indicates the number of times the value should be returned by mock_int(). If count is set to -1, the value will always be returned but must be returned at least once. If count is set to -2, the value will always be returned by mock_int(), but is not required to be returned. |
| void will_return_int_maybe | ( | # | function, |
| intmax_t | value ) |
Store an integer value that may always be returned by mock_int().
This stores a value which will always be returned by mock_int() but is not required to be returned by at least one call to mock_int(). Therefore, in contrast to will_return_int_always() which causes a test failure if it is not returned at least once, will_return_int_maybe() will never cause a test to fail if its value is not returned.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_int(). |
This is equivalent to:
| void will_return_maybe | ( | # | function, |
| uintmax_t | value ) |
| void will_return_ptr | ( | # | function, |
| void * | value ) |
Store a pointer value to be returned by mock_ptr_type() later.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_ptr_type(). |
| void will_return_ptr_always | ( | # | function, |
| void * | value ) |
Store a value that will be always returned by mock_ptr_type().
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_ptr_type(). |
This is equivalent to:
| void will_return_ptr_count | ( | # | function, |
| void * | value, | ||
| int | count ) |
Store a pointer value to be returned by mock_ptr_type() later.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_ptr_type(). | |
| [in] | count | The parameter indicates the number of times the value should be returned by mock(). If count is set to -1, the value will always be returned but must be returned at least once. If count is set to -2, the value will always be returned by mock(), but is not required to be returned. |
| void will_return_ptr_maybe | ( | # | function, |
| void * | value ) |
Store a value that may be always returned by mock_ptr_type().
This stores a value which will always be returned by mock_ptr_type() but is not required to be returned by at least one call to mock_ptr_type(). Therefore, in contrast to will_return_ptr_always() which causes a test failure if it is not returned at least once, will_return_ptr_maybe() will never cause a test to fail if its value is not returned.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_ptr_type(). |
This is equivalent to:
| void will_return_ptr_type | ( | # | function, |
| void * | value, | ||
| type | ) |
Store a pointer value to be returned by mock_ptr_type_checked() later.
This will also check that the type matches and if not will fail(). The type checking only works when used in conjunction with mock_ptr_type_checked(). If you use mock_ptr_type() to retrieve the value, no type checking will occur.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_ptr_type_checked(). | |
| [in] | type | The type of the pointer. const char *return_pointer(void)
{
}
static void test_pointer_return(void **state)
{
assert_string_equal(my_func_calling_return_pointer(), "hello world");
}
|
| void will_return_uint | ( | # | function, |
| uintmax_t | value ) |
Store a unsigned integer value to be returned by mock() later.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock(). |
| void will_return_uint_always | ( | # | function, |
| uintmax_t | value ) |
Store an unsigned integer value that will always be returned by mock_uint().
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_uint(). |
This is equivalent to:
| void will_return_uint_count | ( | # | function, |
| uintmax_t | value, | ||
| int | count ) |
Store an unsigned integer value to be returned a specified number of times by mock() later.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock(). | |
| [in] | count | The parameter indicates the number of times the value should be returned by mock_uint(). If count is set to -1, the value will always be returned but must be returned at least once. If count is set to -2, the value will always be returned by mock_uint(), but is not required to be returned. |
| void will_return_uint_maybe | ( | # | function, |
| uintmax_t | value ) |
Store an unsigned integer value that may always be returned by mock_uint().
This stores a value which will always be returned by mock_uint() but is not required to be returned by at least one call to mock_uint(). Therefore, in contrast to will_return_uint_always() which causes a test failure if it is not returned at least once, will_return_uint_maybe() will never cause a test to fail if its value is not returned.
| [in] | function | The function which should return the given value. | |
| [in] | value | The value to be returned by mock_uint(). |
This is equivalent to:
| void will_set_errno | ( | # | function, |
| intmax_t | value ) |
Store an integer value to set errno to by mock_errno() later.
| [in] | function | The function in which errno should be set to the given value. | |
| [in] | value | The value to set errno to by the call to mock_errno(). |
| void will_set_errno_always | ( | # | function, |
| intmax_t | value ) |
Store an integer value to set errno to by mock_errno() later, for a specified number of times.
This stores a value which will errno will always be set to by mock_errno() but is required to be set least once by a call to mock_errno().
| [in] | function | The function in which errno should be set to the given value. | |
| [in] | value | The value to set errno to by the call to mock_errno(). |
This is equivalent to:
| void will_set_errno_count | ( | # | function, |
| intmax_t | value, | ||
| size_t | count ) |
Store an integer value to always set errno to by mock_errno().
| [in] | function | The function in which errno should be set to the given value. | |
| [in] | value | The value to set errno to by the call to mock_errno(). | |
| [in] | count | The count parameter gives the number of times the value should be validated by check_expected(). If count is set to EXPECT_ALWAYS the value will always be returned, and cmocka expects check_expected() to be issued at least once. If count is set to EXPECT_MAYBE, any number of calls to check_expected() is accepted, including zero. |
| void will_set_errno_maybe | ( | # | function, |
| intmax_t | value ) |
Store an integer value to set errno to by mock_errno() later, for a specified number of times.
This stores a value which will errno will always be set to by mock_errno() and won't fail if mock_errno() is never called.
| [in] | function | The function in which errno should be set to the given value. | |
| [in] | value | The value to set errno to by the call to mock_errno(). |
This is equivalent to:
| void will_set_parameter | ( | # | function, |
| # | name, | ||
| uintmax_t | value ) |
Store a named value to be returned by mock_parameter() later.
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter(). |
| void will_set_parameter_always | ( | # | function, |
| # | name, | ||
| uintmax_t | value ) |
| void will_set_parameter_count | ( | # | function, |
| # | name, | ||
| uintmax_t | value, | ||
| int | count ) |
| void will_set_parameter_double | ( | # | function, |
| # | name, | ||
| double | value ) |
Store a named double precision floating point value to be returned by mock_parameter() later.
And adds some type checking information to be able to check with call to mock_parameter_double().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The double value to be returned by mock_parameter(). |
| void will_set_parameter_double_always | ( | # | function, |
| # | name, | ||
| double | value ) |
Store a named double value that will always be returned by mock_parameter_double().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_double(). |
This is equivalent to:
| void will_set_parameter_double_count | ( | # | function, |
| # | name, | ||
| double | value, | ||
| int | count ) |
Store a named double value to be returned a specified number of times by mock_parameter_double() later.
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_double(). | |
| [in] | count | The parameter indicates the number of times the value should be returned. If count is set to -1, the value will always be returned but must be returned at least once. If count is set to -2, the value will always be returned, but is not required to be returned. |
| void will_set_parameter_double_maybe | ( | # | function, |
| # | name, | ||
| double | value ) |
Store a named double value that may always be returned by mock_parameter_double().
This stores a value which will always be returned by mock_parameter_double() but is not required to be returned by at least one call to mock_parameter_double().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_double(). |
This is equivalent to:
| void will_set_parameter_float | ( | # | function, |
| # | name, | ||
| float | value ) |
Store a named float value to be returned by mock_parameter() later.
And adds some type checking information to be able to check with call to mock_parameter_float().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The float value to be returned by mock_parameter(). |
| void will_set_parameter_float_always | ( | # | function, |
| # | name, | ||
| float | value ) |
Store a named float value that will always be returned by mock_parameter_float().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_float(). |
This is equivalent to:
| void will_set_parameter_float_count | ( | # | function, |
| # | name, | ||
| float | value, | ||
| int | count ) |
Store a named float value to be returned a specified number of times by mock_parameter_float() later.
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_float(). | |
| [in] | count | The parameter indicates the number of times the value should be returned. If count is set to -1, the value will always be returned but must be returned at least once. If count is set to -2, the value will always be returned, but is not required to be returned. |
| void will_set_parameter_float_maybe | ( | # | function, |
| # | name, | ||
| float | value ) |
Store a named float value that may always be returned by mock_parameter_float().
This stores a value which will always be returned by mock_parameter_float() but is not required to be returned by at least one call to mock_parameter_float().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_float(). |
This is equivalent to:
| void will_set_parameter_int | ( | # | function, |
| # | name, | ||
| intmax_t | value ) |
Store a named integer value to be returned by mock_parameter() later.
And adds some type checking information to be able to check with call to mock_parameter_int().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter(). |
| void will_set_parameter_int_always | ( | # | function, |
| # | name, | ||
| intmax_t | value ) |
Store a named integer value that will always be returned by mock_parameter_int().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_int(). |
This is equivalent to:
| void will_set_parameter_int_count | ( | # | function, |
| # | name, | ||
| intmax_t | value, | ||
| int | count ) |
Store a named integer value to be returned a specified number of times by mock_parameter_int() later.
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_int(). | |
| [in] | count | The parameter indicates the number of times the value should be returned. If count is set to -1, the value will always be returned but must be returned at least once. If count is set to -2, the value will always be returned, but is not required to be returned. |
| void will_set_parameter_int_maybe | ( | # | function, |
| # | name, | ||
| intmax_t | value ) |
Store a named integer value that may always be returned by mock_parameter_int().
This stores a value which will always be returned by mock_parameter_int() but is not required to be returned by at least one call to mock_parameter_int().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_int(). |
This is equivalent to:
| void will_set_parameter_maybe | ( | # | function, |
| # | name, | ||
| uintmax_t | value ) |
| void will_set_parameter_ptr | ( | # | function, |
| # | name, | ||
| void * | value ) |
Store a named pointer value to be returned by mock_parameter() later.
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter(). |
| void will_set_parameter_ptr_always | ( | # | function, |
| # | name, | ||
| void * | value ) |
Store a named pointer value that will be always returned by mock_parameter_ptr().
This stores a value which will always be returned by mock_parameter_ptr() and is required to be returned by at least one call to mock_parameter_ptr(). If it is not returned at least once the test will fail.
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_ptr(). |
This is equivalent to:
| void will_set_parameter_ptr_count | ( | # | function, |
| # | name, | ||
| void * | value, | ||
| int | count ) |
Store a named pointer value to be returned a specified number of times by mock_parameter_ptr() later.
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_ptr(). | |
| [in] | count | The parameter indicates the number of times the value should be returned by mock_parameter_ptr(). If count is set to -1, the value will always be returned but must be returned at least once. If count is set to -2, the value will always be returned by mock_parameter_ptr(), but is not required to be returned. |
| void will_set_parameter_ptr_maybe | ( | # | function, |
| # | name, | ||
| void * | value ) |
Store a named pointer value that may be always returned by mock_parameter_ptr().
This stores a value which will always be returned by mock_parameter_ptr() but is not required to be returned by at least one call to mock_parameter_ptr(). Therefore, in contrast to will_set_parameter_ptr_always() which causes a test failure if it is not returned at least once, will_set_parameter_ptr_maybe() will never cause a test to fail if its value is not returned.
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_ptr(). |
This is equivalent to:
| void will_set_parameter_ptr_type | ( | # | function, |
| # | name, | ||
| void * | value, | ||
| # | type ) |
Store a named pointer value to be returned by mock_parameter() later.
This will also check that the type matches and if not will fail().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter(). | |
| [in] | type | The type of the pointer. |
| void will_set_parameter_uint | ( | # | function, |
| # | name, | ||
| uintmax_t | value ) |
Store a named unsigned integer value to be returned by mock_parameter() later.
And adds some type checking information to be able to check with call to mock_parameter_uint().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter(). |
| void will_set_parameter_uint_always | ( | # | function, |
| # | name, | ||
| uintmax_t | value ) |
Store a named unsigned integer value that will always be returned by mock_parameter_uint().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_uint(). |
This is equivalent to:
| void will_set_parameter_uint_count | ( | # | function, |
| uintmax_t | value, | ||
| int | count ) |
Store a named unsigned integer value to be returned a specified number of times by mock_parameter_uint() later.
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_uint(). | |
| [in] | count | The parameter indicates the number of times the value should be returned. If count is set to -1, the value will always be returned but must be returned at least once. If count is set to -2, the value will always be returned, but is not required to be returned. |
| void will_set_parameter_uint_maybe | ( | # | function, |
| # | name, | ||
| uintmax_t | value ) |
Store a named unsigned integer value that may always be returned by mock_parameter_uint().
This stores a value which will always be returned by mock_parameter_uint() but is not required to be returned by at least one call to mock_parameter_uint().
| [in] | function | The function in which the given value should be return. | |
| [in] | name | The name under which the given value should be returned. | |
| [in] | value | The value to be returned by mock_parameter_uint(). |
This is equivalent to: