1 /* Copyright (c) 2024 Google LLC
2  * SPDX-License-Identifier: Apache-2.0
3  */
4 
5 #pragma once
6 
7 #include <functional>
8 
9 /*
10  * We need to override fff's function signature away from a standard function pointer.
11  * By using std::function<> we're able to leverage capture variables since additional storage must
12  * be allocated for them. In the tests, we will include asserts in the lambda functions. This
13  * provides the ability to assert inside the lambda and get errors that map to a line within the
14  * test function. If we use plain function pointers, we have to move the expected value outside
15  * of the test function and make it a static global of the compilational unit.
16  *
17  * Example:
18  * @code
19  * const uint8_t expected_value = 40;
20  * my_function_fake.custom_fake = [&expected_value](uint8_t value) {
21  *   zassert_equal(expected_value, value);
22  * };
23  * my_function(expected_value);
24  * @endcode
25  */
26 #define CUSTOM_FFF_FUNCTION_TEMPLATE(RETURN, FUNCNAME, ...)                                        \
27 	std::function<RETURN(__VA_ARGS__)> FUNCNAME
28 
29 #include <zephyr/fff.h>
30 
31 DECLARE_FAKE_VALUE_FUNC(int, blocking_emul_i2c_transfer, const struct emul *, struct i2c_msg *, int,
32 			int);
33