Is Google Test OK for testing C code?

Jason picture Jason · Mar 17, 2011 · Viewed 41.4k times · Source

So I've come to like and enjoy using Google Test for a C++ project I'm involved in. I'm just bringing up a new project that will be straight C (a library) and so far can't see any reason why not to continuing using Google Test, even though its a C++ framework. Having a C++ compiler available will not be an issue.

Are there are specific reasons why I shouldn't use Google Test for testing straight C code?

Thanks.

Answer

mikelong picture mikelong · Jun 2, 2011

It is pretty common to test C code using a C++ testing frameworks, even the leading book on the subject follows this approach. I have used googletest extensively in the past to unit test C code and can recommend it.

I have written a blog post about it that might be useful: http://meekrosoft.wordpress.com/2009/11/09/unit-testing-c-code-with-the-googletest-framework/