I am working on a procedural C/C++ project. The public interface consists of 4 functions, each with fairly complex tasks. There are helper functions declared in the same cpp
file, in an unnamed namespace. The test framework being used is GTest.
However, some of these helper functions are becoming complex enough to require their own unit testing. Normally, I would refactor these helpers into their own testable units, but the project requirements state everything needs to be in the one cpp
, and only the specified functions can be publicly visible.
Is there a way I can unit test the helper functions while minimizing coupling, and following the project requirements as closely as possible?
A possible solution I had was to use a macro to turn the namespace into a named one for testing, and unnamed for production. However, that seemed a bit messier than I would like.