Make the test class as the friend of the original class. This friend declaration will be inside the #define UNIT_TEST
flag.
class To_test_class {
#ifdef UNIT_TEST
friend test_class;
#endif
}
Now for your unit test you will compile the code with flag -DUNIT_TEST
. This way you will be able to test the private function.
Now your unit test code will not be pushed into production environment, as UNIT_TEST
flag will be false. Hence the code is still secure.
Also you will not need any special library for unit testing.