diff --git a/README.md b/README.md index 9f0cd76..1f5aeef 100644 --- a/README.md +++ b/README.md @@ -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 SET_RETURN_SEQ 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...