I have a function defined in a translation unit file (.cpp) something like:
void myFunction(int option)
{
if (option == 0)
{
Meth1("arg1");
}
else
{
if (option == 1)
{
Meth1("arg2");
}
else
{
Meth2("arg3");
}
}
}
This function has its definition in a header file but is not part of a class or struct it is just implemented in the cpp file as above. No refactoring is allowed.
Now I need to write a unit test for it to check which method is called based on the option argument. Something like in test I have
myFunction(0);
now I am testing that the Meth1 is called and its parameter has the "arg1" value.
Is it possible to write such a test ?