forked from 3rd-party/fff
Added custom fake information to the readme documentation
This commit is contained in:
27
README.md
27
README.md
@@ -250,6 +250,23 @@ 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.
|
||||
|
||||
## Custom Return Value Delegate
|
||||
|
||||
You can specify your own function to provide the return value for the fake. This
|
||||
is done by setting the custom_fake member of the fake. Here's an example:
|
||||
|
||||
#define MEANING_OF_LIFE 42
|
||||
long my_custom_value_fake(void)
|
||||
{
|
||||
return MEANING_OF_LIFE;
|
||||
}
|
||||
TEST_F(FFFTestSuite, when_value_custom_fake_called_THEN_it_returns_custom_return_value)
|
||||
{
|
||||
longfunc0_fake.custom_fake = my_custom_value_fake;
|
||||
long retval = longfunc0();
|
||||
ASSERT_EQ(MEANING_OF_LIFE, retval);
|
||||
}
|
||||
|
||||
|
||||
## Find out more...
|
||||
|
||||
@@ -262,20 +279,14 @@ There is also a test suite for the framework under the test directory.
|
||||
So whats the point?
|
||||
|
||||
* To make it easy to create fake functions for testing C code.
|
||||
* To be simple
|
||||
* To work in both C and C++ test environments
|
||||
|
||||
## What can it do?
|
||||
* It maintains a call count for each fake function
|
||||
* It captures the arguments sent in each function call
|
||||
* It captures a call history
|
||||
* It is simple - just include a header file and you are good to go.
|
||||
* To work in both C and C++ test environments
|
||||
|
||||
|
||||
## Under the hood:
|
||||
* The fff.h header file is generated by a ruby script
|
||||
* There are tests under src/test
|
||||
* There are examples for testing an embedded UI under src/examples
|
||||
* There is an example for testing an embedded UI and a hardware driver under src/examples
|
||||
|
||||
|
||||
## Cheat Sheet
|
||||
|
||||
Reference in New Issue
Block a user