malsyned / pfstest

Professional Firmware Services Unit Test Framework
Other
1 stars 0 forks source link

Multiple identical invocations are not correctly verified in_order #52

Closed malsyned closed 6 years ago

malsyned commented 6 years ago

Test case:

test(should_recognize_identical_function_call_twice_in_order) { in_order_t *order = in_order_new();

in_order_verify(order, when(mock_dep_func4));
in_order_verify(order, when(mock_dep_func4));

dep_func4();
dep_func4();

}

malsyned commented 6 years ago

Each call to when() creates a new expectation, with e->times == PFSTEST_EXPECTATION_DO_TIMES_INFINITE;

So both calls to dep_func4() create an invocation object with its expectation field set to the first e, and the second e is never found on the invocation list.

The straight-forward simple solution to this is to set expectation->times to 1 in in_order_verify, which is consistent with my spec and design anyway.