| Info |
|---|
Stub API require the Enable Stub API option option to be enabled in the Stubs view (see see Configuring Stub Options in the Stubs View) or directly in your test configuration (see Execution Tab Settings - Defining How Tests are Executed) before the stub is created. |
...
You can enforce the returning integer value 5 for all calls to the stub.
Code Block [C++] CPPTEST_ON_CALL("foo").Arg("__return").Assign(5); [C] CPPTEST_ON_CALL("foo")->Arg("__return").Assign()->Int(5);You can enforce the return value depending on the stub parameter value. In the following example, the returning integer value
5for the calls to the stub where parameterparam1is equal to the integer value0is enforced. For all other cases, the default value is returned (0for numerical types).Code Block [C++] CPPTEST_ON_CALL("foo").If().Arg("param1").Equal(0).Arg("__return").Assign(5); [C] CPPTEST_ON_CALL("foo")->If()->Arg("param1")->Equal()->Int(0)->Arg("__return")->Assign()->Int(5);You can call the original function and modify return values. In the following example, the original function is called and the return value is modified to the integer value of 5.
Code Block [C++] CPPTEST_ON_CALL("foo").Arg("__callOrig").Assign(1).Arg("__return").Assign(5); [C] CPPTEST_ON_CALL("foo")->Arg("__callOrig")->Assign()->Int(1)->Arg("__return")->Assign()->Int(5);
...