mirror of
https://github.com/meekrosoft/fff
synced 2026-01-23 08:25:59 +01:00
Adding documentation for return value sequences
This commit is contained in:
24
README.md
24
README.md
@@ -222,7 +222,29 @@ Coming soon!
|
|||||||
|
|
||||||
## Function Return Value Sequences
|
## Function Return Value Sequences
|
||||||
|
|
||||||
Coming soon!
|
Often in testing we would like to test the behaviour of sequence of function call
|
||||||
|
events. One way to do this with fff is to specify a sequence of return values
|
||||||
|
with for the fake function. It is probably easier to describe with an example:
|
||||||
|
|
||||||
|
// faking "long longfunc();"
|
||||||
|
FAKE_VALUE_FUNC0(long, longfunc0);
|
||||||
|
|
||||||
|
TEST_F(FFFTestSuite, return_value_sequences_exhausted)
|
||||||
|
{
|
||||||
|
long myReturnVals[3] = { 3, 7, 9 };
|
||||||
|
SET_RETURN_SEQ(longfunc0, myReturnVals, 3);
|
||||||
|
ASSERT_EQ(myReturnVals[0], longfunc0());
|
||||||
|
ASSERT_EQ(myReturnVals[1], longfunc0());
|
||||||
|
ASSERT_EQ(myReturnVals[2], longfunc0());
|
||||||
|
ASSERT_EQ(myReturnVals[2], longfunc0());
|
||||||
|
ASSERT_EQ(myReturnVals[2], longfunc0());
|
||||||
|
}
|
||||||
|
|
||||||
|
By specifying a return value sequence using the <tt>SET_RETURN_SEQ<tt> macro,
|
||||||
|
the fake will return the values given in the parameter array in sequence. When
|
||||||
|
the end of the sequence is reached the fake will continue to return the last
|
||||||
|
value in the sequence indefinitely.
|
||||||
|
|
||||||
|
|
||||||
## Find out more...
|
## Find out more...
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user