class A
{
public:
int ret1();
};
int ret()
{
printf("Returning 5\n");
return 5;
}
int A::ret1()
{
int iRet = 10;
printf("Inside ret1\n");
iRet = ret();
if (iRet == 5)
{
printf("Original ret is called\n");
}
else if (iRet == 100)
{
printf("This is mocked function call\n");
}
else
{
printf("Opps! This should not happen\n");
}
return iRet;
}
In the above ret1
function I would like to mock the return value of ret
function's. Normally ret
returns 5
but after mocking lets say ret
will return 100 so ret1
will print "This is mocked function call"
.
Is there any tool to do the above situation. So as far I know cmocka can cover the above situation for C language but for C++ is there any tool available?
In the link Mocking free function doesn't look like answering my question.