How a unit test can be made for this kind of structure?
How to change the call so function a()
will call function mock_b()
instead of function b()
.
// source.h
int b(int x);
bool a();
// source.cpp
int b(int x){return x;}
bool a(){return (b(5) > 0);}
// tester.cpp
#include "source.h"
int mock_b(int x){return -8;}
unit_test(){
assert(true == a());
b = mock_b; //How this replacement can be done?
assert(false == a());
}