I have a function that I'm testing, f1().
f1() calls g1() which can return a few different values.
How do I mock g1() so I can iterate through the different values it returns in order to test the paths inside f1()?
int f1()
{
int res = g1();
int ret = 0;
switch(res):
{
case 0:
// ret = something
case 1:
// ret = something else
default:
// ret = bad result
}
return ret;
}
Answer
Probably you can try cmocka
tool to do the above mentioned use case.
No comments:
Post a Comment