How to use Parasoft C++ Dynamic stubs

wsuberswsubers Posts: 6

Hello Community,

I am a first time user of Parasoft's dynamic stubs. I am evaluating this feature as an alternate to using Google mock.

If I have a function:

void Func3()
{
int b = 1;
Func4(*b);
Func5(b);
}

In my test case for testing 3 what is the appropriate Dynamic Stubs calls to have Func4 output the value of b to 5 and validate the input parameter to Func5 was 5??

Thank you,
Bill

Comments

  • piotrpiotr Posts: 14

    Hello,

    Assuming:

    void Func4(int * bptr);
    void Func5(int b);
    

    You could do it like this:

    CPPTEST_ON_CALL("Func4")->Arg("bptr")->At()->Int(0)->Assign()->Int(5);
    CPPTEST_ON_CALL("Func5")->If()->Arg("b")->NotEqual()->Int(5)->Fail("Invalid state: b != 5");
    
Sign In or Register to comment.