If you are using a C++ compiler for your "C code", you should be fine. However, if you are using a true C compiler, you might have issues since CppUnit uses classes. It's been a while since I used a real C compiler, so I'm not sure whether the linker will complain or not.
I suggest that You make an simple function and tests for it to see what happens.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I expect that the C 'purists' out there would think that this was a quite a bad thing.
I'd suggest that it's perhaps not so bad, but you should try to set things up so that your tested code is compiled by a pure C compiler, perhaps as a shared library, so that the only way a C++ compiler gets near your code is via #includes and via the linker. This will ensure you don't get any C++-isms creeping in to your C code.
Another option would be to add simple SWIG bindigs to your code and using something like Python to test it. Given the amount of time you spend waiting for a compiler while writing test code, this can possibly be a good thing. I'm sure it depends on the type of code you're testing: the nature of your data structures and API and so on.
Cheers
JP
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
While quickly studying CppUnit for the needs of my project I did not notice any obstacles for using it with C code as well as Cpp code.
Is it fully suitable for C code in your opinion, or shall I look at the CUnit and the like?
If you are using a C++ compiler for your "C code", you should be fine. However, if you are using a true C compiler, you might have issues since CppUnit uses classes. It's been a while since I used a real C compiler, so I'm not sure whether the linker will complain or not.
I suggest that You make an simple function and tests for it to see what happens.
I expect that the C 'purists' out there would think that this was a quite a bad thing.
I'd suggest that it's perhaps not so bad, but you should try to set things up so that your tested code is compiled by a pure C compiler, perhaps as a shared library, so that the only way a C++ compiler gets near your code is via #includes and via the linker. This will ensure you don't get any C++-isms creeping in to your C code.
Another option would be to add simple SWIG bindigs to your code and using something like Python to test it. Given the amount of time you spend waiting for a compiler while writing test code, this can possibly be a good thing. I'm sure it depends on the type of code you're testing: the nature of your data structures and API and so on.
Cheers
JP