Testing modules in C ++ and creating a library of third-party C developers

I need unit test some C ++ objects that I wrote that use a third-party C library. For reasons beyond the scope of this question, I cannot directly call a third-party C library, and you need to drown it for a set of tests.

For other parts of our unit test googlemock , we use googlemock , but I don't think it can be used for C libraries. I can finish the library manually, but I don’t prefer (partly because of laziness (its quite large), but mainly because it is only a matter of principles).

So, here is my question: is there a tool that generates encoded code based on the C library header file? As soon as I get the code, I will make some small mods, and then I will contact him for unit testing.

+4
source share
2 answers

stubgen can generate stub members from header files if you do not have special requirements that it must fulfill what you are looking for.

+3
source

You cannot transfer these calls to a class as described in http://code.google.com/p/googlemock/wiki/CookBook#Mocking_Free_Functions

Then you can enter (in a dynamic or static way) this class and set expectations on it.

+1
source

All Articles