I'm using cpputest to perform Unit Tests of c code.
In my source code under test I have a static function which I would like to be "redirected" to a "faked" version of the function when called from the unit test environment.
Let's say, I have somethig like this:
Source Code under test:
void my_main()
{
read(int8 address);
}
whereby;
static int8 read(int8 address)
{
return something;
}
Unit Test Environment:
TEST(MY_TESTS, READ)
{
my_main();
}
When calling my_main() within Unit Test environment, I would like to redirect the call of
read(int8 address) to:
int8 fake_read(int8 address)
{
//do_something
}
What will be here the correct way? I tried it already with function pointer than injection of the dependency but it does not work. Any idea?