Skip to content

Commit 7d8c325

Browse files
anrivoalrzr
authored andcommitted
libs2/tf: NOJIRA: allow to declare mock with multiple calls (SiliconLabsSoftware#57)
(cherry picked from commit 299c26d472c31e68f0d38734aee17304aa1690b9) Forwarded: SiliconLabsSoftware#57 Relate-to: SiliconLabsSoftware#50 Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
1 parent bbddceb commit 7d8c325

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

applications/zpc/components/zwave/zwave_transports/s2/libs/zw-libs2/TestFramework/mock/mock_control.c

+12
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ void mock_call_expect_ex(uint32_t line_number, const char * p_func_name, mock_t
4848
*pp_mock = &mock_call_db[mock_db_idx];
4949
(*pp_mock)->p_func_name = p_func_name;
5050
(*pp_mock)->executed = false;
51+
(*pp_mock)->multiple = false;
5152
(*pp_mock)->line_number = line_number;
5253
(*pp_mock)->mock_id = 0;
5354
mock_db_idx++;
@@ -121,6 +122,17 @@ bool mock_call_find(char const * const p_function_name, mock_t ** pp_mock)
121122
return true;
122123
}
123124
}
125+
for (i = 0; i < mock_db_idx; i++)
126+
{
127+
if ((true == mock_call_db[i].multiple) &&
128+
strcmp(mock_call_db[i].p_func_name, p_function_name) == 0)
129+
{
130+
*pp_mock = &mock_call_db[i];
131+
g_mock_index = i;
132+
return true;
133+
}
134+
}
135+
124136
mock_db_idx = 0;
125137
stub_db_idx = 0;
126138
fake_db_idx = 0;

applications/zpc/components/zwave/zwave_transports/s2/libs/zw-libs2/TestFramework/mock/mock_control.h

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ typedef struct
9393
the function and not to be mistaken with output values provided thought pointer
9494
parameters of the function. To have the function returning the value 10, simply do:
9595
p_mock->return_code.value = 10; */
96+
bool multiple; /**< Allow multiple calls*/
9697
mock_rules_t compare_rule_arg[NUMBER_OF_ARGS]; /**< Compare rule to be used for parameter at index n.
9798
Default compare rule is COMPARE_STRICT. So this value needs only to be set if the
9899
parameter should be checked against a different rule, as example, COMPARE_ANY.

0 commit comments

Comments
 (0)