Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to use Parasoft C++ Dynamic stubs

wsubers
wsubers Posts: 7

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

  • piotr
    piotr Posts: 36

    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");