You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See header comment in fff.h for details -- summary extracted below:
Return value macros:
SET_RETURN_VAL_SEQ(function_name, ...)
Accepts a raw list of appropriately typed values
SET_RETURN_VAL(function_name, value)
Provided for API consistency
Assertion macros:
TEST_ASSERT_CALLS(function_name, expected_call_count)
TEST_ASSERT_CALLED(function_name)
Only one call made to the function.
TEST_ASSERT_NOT_CALLED(function_name)
No calls made to the function.
TEST_ASSERT_CALL(function_name, ...parameters)
Only one call made to the function with the specified parameter values.
TEST_ASSERT_LAST_CALL(function_name, ...parameters)
The final call to this function was made with the specified parameter values.
TEST_ASSERT_ANY_CALL(function_name, ...parameters)
At least one call was made with the specified parameter values.
TEST_ASSERT_NO_CALL(function_name, ...parameters)
No calls were made with the specified parameter values.
TEST_ASSERT_NTH_CALL(function_name, call_index, ...parameters)
A specified invocation of the function used the specified parameter values.
<<Amendment 1>>
Added unit tests.
Added TEST_ASSERT_CALL(...), as couldn't get optional parameter verification for
TEST_ASSERT_CALLED to work in c99 mode.
<<Amendment 2>>
Updated generator.
Function name changes for consistency.
Initial documentation updates.
<<Amendment 3>>
FFF_RETURN: Made array declaration static to allow use in a fixture setup method
| FAKE_VOID_FUNC(fn [,arg_types*]); | Define a fake function named fn returning void with n arguments | FAKE_VOID_FUNC(DISPLAY_output_message, const char*); |
585
-
| FAKE_VALUE_FUNC(return_type, fn [,arg_types*]); | Define a fake function returning a value with type return_type taking n arguments | FAKE_VALUE_FUNC(int, DISPLAY_get_line_insert_index); |
586
-
| RESET_FAKE(fn); | Reset the state of fake function called fn | RESET_FAKE(DISPLAY_init); |
| FAKE_VOID_FUNC(fn [,arg_types*]); | Define a fake function named fn returning void with n arguments | FAKE_VOID_FUNC(DISPLAY_output_message, const char*); |
661
+
| FAKE_VALUE_FUNC(return_type, fn [,arg_types*]); | Define a fake function returning a value with type return_type taking n arguments | FAKE_VALUE_FUNC(int, DISPLAY_get_line_insert_index); |
662
+
| RESET_FAKE(fn); | Reset the state of fake function called fn | RESET_FAKE(DISPLAY_init); |
663
+
| FFF_RETURN(fn, ...return_value(s)*); | Set one or more return values (final value repeated if calls > values) | FFF_RETURN(DISPLAY_init, 1, 2, 3); |
664
+
| FFF_ASSERT_CALLED(fn); | Assert that a function was called once and only once. | FFF_ASSERT_CALLED(DISPLAY_init); |
665
+
| FFF_ASSERT_NOT_CALLED(fn); | Assert that a function was not called. | FFF_ASSERT_NOT_CALLED(DISPLAY_init); |
666
+
| FFF_ASSERT_CALLS(fn, call_count); | Assert that a function was called the specified number of times. | FFF_ASSERT_CALLS(DISPLAY_init, 3); |
667
+
| FFF_ASSERT(fn, ...arg_value(s)) | Assert that a function was called only once with the specified argument values. | FFF_ASSERT(DISPLAY_output_message, my_message_ptr); |
668
+
| FFF_ASSERT_LAST(fn, ...arg_value(s)) | Assert that the last call to a function had the specified argument values. | FFF_ASSERT_LAST(DISPLAY_output_message, my_message_ptr); |
669
+
| FFF_ASSERT_ANY(fn, ...arg_value(s)) | Assert that any call to a function had the specified argument values. | FFF_ASSERT_ANY(DISPLAY_output_message, my_message_ptr); |
670
+
| FFF_ASSERT_NONE(fn, ...arg_value(s)) | Assert that no calls to a function had the specified argument values. | FFF_ASSERT_NONE(DISPLAY_output_message, my_message_ptr); |
671
+
672
+
*N.B.* All of the function argument assertions support partial specification of arguments. I.e. Given a function taking 3 args, you may just specify the first argument for verification. Any arguments that are specified must be specified from left to right however. i.e. it is possibly to specify arguments 0 and 1, but not arguments 0 and 2 (ignoring the value of 1).
0 commit comments