Hi Alexander,
Firstly, I extend Cmockery to support bunch of macros:
Use check_expected_and_optional_assig(parameter) in mock code.
Use following macros in test code.
will_assign_string(function, parameter, string)
will_assign_string_count(function, parameter, string, count)
will_assign_memory(function, parameter, memory,size)
will_assign_memory_count(function, parameter, memory, size, count)
will_assign_struct(function, parameter, assign_function,value)
will_assign_struct_count(function, parameter, assign_function, value,
count)
Then a simple rule to generate mocks from headers is:
{return_type} function_name({arg1_type} arg1_anme,{arg2_type}
arg2_name);
=>
{return_type} function_name({arg1_type} arg1_anme,{arg2_type}
arg2_name)
{
check_expected_and_optional_assign(arg1_name);
check_expected_and_optional_assign(arg2_name);
return ({return_type})mock();
}
In test code, it is forced to expect all arguments, and modify
arguments optionally.
Regards,
-Bob
On Jul 22, 4:17 pm, Alexander Demin <
ade...@gmail.com> wrote:
> Bob,
> I also work with lots of legacy code on C и C++ and try to inject Google
> Test and Cmockery tools into that code.
>
> Could you please give an example how do you generate mocks from headers?
>
> Alexander
>