I'm trying out unit test with the CppUTest framework. I'm using it on an existing code module and need to make doubles for many of the functions included by the module. Making doubles for functions works well, but I'm having problems with structs included into the modul开发者_如何转开发e alongside the functions. How do I include test doubles for structs?
Generally you should use the real struct, unless you are faking a module that is built around an abstract data type. Then you define the ADT struct in the double.
If you are really asking how do you test with global structures, you can create a defining instance of the struct in the test case or a test helper file.
If neither of these ideas fit your situation, please give some more details or an example.
James
I solved it by including all the surrounding modules thereby also including the structs and then substitution the functions when linker.
精彩评论