Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Getting and Giving Help" section to README #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ you want to create a fake for:
```c
// UI.c
...
void DISPLAY_init();
void DISPLAY_init(void);
...
```

Expand Down Expand Up @@ -119,7 +119,7 @@ TEST_F(UITests, write_line_outputs_lines_to_display)
char msg[] = "helloworld";
UI_write_line(msg);
ASSERT_EQ(DISPLAY_output_fake.call_count, 1);
ASSERT_EQ(strncmp(DISPLAY_output_fake.arg0_val, msg, 26), 0);
ASSERT_EQ(strncmp(DISPLAY_output_fake.arg0_val, msg, strlen(msg)), 0);
}
```

Expand All @@ -140,8 +140,8 @@ When you want to define a fake function that returns a value, you should use the
```c
// UI.c
...
unsigned int DISPLAY_get_line_capacity();
unsigned int DISPLAY_get_line_insert_index();
unsigned int DISPLAY_get_line_capacity(void);
unsigned int DISPLAY_get_line_insert_index(void);
...
```

Expand Down Expand Up @@ -187,7 +187,7 @@ call counts. It is good practice is to call the reset function for all the
fakes in the setup function of your test suite.

```c
void setup()
void setup(void)
{
// Register resets
RESET_FAKE(DISPLAY_init);
Expand All @@ -209,7 +209,7 @@ You might want to define a macro to do this:
FAKE(DISPLAY_get_line_capacity) \
FAKE(DISPLAY_get_line_insert_index)

void setup()
void setup(void)
{
/* Register resets */
FFF_FAKES_LIST(RESET_FAKE);
Expand Down Expand Up @@ -639,15 +639,13 @@ Look under the examples directory for full length examples in both C and C++.
There is also a test suite for the framework under the test directory.

-------------------------

## Benefits
So whats the point?

* To make it easy to create fake functions for testing C code.
* 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 _./test_
Expand All @@ -663,3 +661,15 @@ So whats the point?
| FAKE_VOID_FUNC_VARARG(fn [,arg_types*], ...); | Define a fake variadic function returning void with type return_type taking n arguments and n variadic arguments | FAKE_VOID_FUNC_VARARG(fn, const char*, ...) |
| FAKE_VALUE_FUNC_VARARG(return_type, fn [,arg_types*], ...); | Define a fake variadic function returning a value with type return_type taking n arguments and n variadic arguments | FAKE_VALUE_FUNC_VARARG(int, fprintf, FILE*, const char*, ...) |
| RESET_FAKE(fn); | Reset the state of fake function called fn | RESET_FAKE(DISPLAY_init); |

-------------------------
## Getting (and Giving) Help

If you've found a bug or want to suggest an improvement,
[create an issue](https://github.com/meekrosoft/fff/issues) and possibly
[generate a pull request]
(https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).
If you want help from the fff community, the best bet at present is to
[ask a question on Stack Overflow](https://stackoverflow.com/questions/ask)
and tag the question with `fake-function-framework`. Using that tag also makes it
easy to [find other fff questions on Stack Overflow](https://stackoverflow.com/questions/tagged/fake-function-framework).