Adding documentation for return value sequences

This commit is contained in:
Mike Long
2011-03-22 21:50:10 +01:00
parent c44f725fb7
commit f02e387a40

View File

@@ -222,7 +222,29 @@ Coming soon!
## 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...