Macro
STUB
Stub a function so it always returns a specific value.
Since v1.0
#define STUB(
FUNC,
VALUE)
Parameters 🔗
FUNC | in | Function to be mocked. |
VALUE | in | Value to return from FUNC. |
Discussion 🔗
This is identical to the purpose of the FAKE macro when the fake functions only purpose is to return a value. Using this macro instead avoids having to manually write the fake function.
The type of VALUE must be an arithmetic or pointer type. It must match the return type of FUNC otherwise the behavior is undefined.
This function-like macro is intended to be called from the body of a test case or fixture. Invoking it elsewhere will produce a runtime error.
Stubbing is discussed in detail in Mocking with Stubs.