From fcc7f1c46f0377f43e09b2bb2f64ee3d6860da92 Mon Sep 17 00:00:00 2001 From: nabijaczleweli Date: Sun, 8 Oct 2017 01:44:10 +0200 Subject: [PATCH] Use markdown instead of inline HTML in README --- README.md | 51 +++++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 89da217..5d4ca5c 100644 --- a/README.md +++ b/README.md @@ -40,14 +40,14 @@ TEST_F(GreeterTests, init_initialises_display) ``` So what has happened here? The first thing to note is that the framework is -header only, all you need to do to use it is download fff.h and include +header only, all you need to do to use it is download `fff.h` and include it in your test suite. -The magic is in the FAKE_VOID_FUNC. This -expands a macro that defines a function returning void +The magic is in the `FAKE_VOID_FUNC`. This +expands a macro that defines a function returning `void` which has zero arguments. It also defines a struct -"function_name"_fake which contains all the information about the fake. -For instance, DISPLAY_init_fake.call_countis incremented every time the faked +`"function_name"_fake` which contains all the information about the fake. +For instance, `DISPLAY_init_fake.call_count`is incremented every time the faked function is called. Under the hood it generates a struct that looks like this: @@ -96,20 +96,20 @@ TEST_F(UITests, write_line_outputs_lines_to_display) ``` -There is no more magic here, the FAKE_VOID_FUNC works as in the +There is no more magic here, the `FAKE_VOID_FUNC` works as in the previous example. The number of arguments that the function takes is calculated, and the macro arguments following the function name defines the argument type (a char pointer in this example). A variable is created for every argument in the form -"function_name"fake.argN_val +`"function_name"fake.argN_val` ## Return values When you want to define a fake function that returns a value, you should use the -FAKE_VALUE_FUNC macro. For instance: +`FAKE_VALUE_FUNC` macro. For instance: ```c // UI.c @@ -198,7 +198,7 @@ void setup() ## Call history Say you want to test that a function calls functionA, then functionB, then -functionA again, how would you do that? Well fff maintains a call +functionA again, how would you do that? Well `fff` maintains a call history so that it is easy to assert these expectations. Here's how it works: @@ -219,7 +219,7 @@ TEST_F(FFFTestSuite, calls_in_correct_order) } ``` -They are reset by calling FFF_RESET_HISTORY(); +They are reset by calling `FFF_RESET_HISTORY();` ## Default Argument History @@ -267,7 +267,7 @@ function is called ## User Defined Argument History If you wish to control how many calls to capture for argument history you can -override the default by defining it before include the fff.h like this: +override the default by defining it before include the `fff.h` like this: ```c // Want to keep the argument history for 13 calls @@ -301,7 +301,7 @@ TEST_F(FFFTestSuite, return_value_sequences_exhausted) } ``` -By specifying a return value sequence using the SET_RETURN_SEQ macro, +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. @@ -542,25 +542,8 @@ So whats the point? ## Cheat Sheet - - - - - - - - - - - - - - - - - - - - - -
MacroDescriptionExample
FAKE_VOID_FUNC(fn [,arg_types*]);Define a fake function named fn returning void with n argumentsFAKE_VOID_FUNC(DISPLAY_output_message, const char*);
FAKE_VALUE_FUNC(return_type, fn [,arg_types*]);Define a fake function returning a value with type return_type taking n argumentsFAKE_VALUE_FUNC(int, DISPLAY_get_line_insert_index);
RESET_FAKE(fn);Reset the state of fake function called fnRESET_FAKE(DISPLAY_init);
+| Macro | Description | Example | +|-------|-------------|---------| +| FAKE_VOID_FUNC(fn [,arg_types*]); | Define a fake function named fn returning void with n arguments | FAKE_VOID_FUNC(DISPLAY_output_message, const char*); | +| FAKE_VALUE_FUNC(return_type, fn [,arg_types*]); | Define a fake function returning a value with type return_type taking n arguments | FAKE_VALUE_FUNC(int, DISPLAY_get_line_insert_index); | +| RESET_FAKE(fn); | Reset the state of fake function called fn | RESET_FAKE(DISPLAY_init); |