From ed376999a3a89946975d5f8e5a64723d97f30544 Mon Sep 17 00:00:00 2001 From: fanasina Date: Mon, 9 Oct 2023 10:10:33 +0200 Subject: [PATCH] Update README.md --- README.md | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/README.md b/README.md index c2281a7..e5ed0da 100644 --- a/README.md +++ b/README.md @@ -88,5 +88,110 @@ For example, to launch tests (`test/is_good.c`) on 4 threads, using unicolor(bla ``` +# How to create test +``` +#include "ftest/ftest.h" + +TEST(nametest){ + EXPECT_EQ(1,1); +} +/* allow empty nametest, e.g*/ +TEST(){} +/* allow duplicate name test, to have suit test */ +TEST(){ + EXPECT_TRUE(true); +} +``` +## in main func +### if using options: +``` +int main(int arc, char** argv){ + run_all_tests_args(argc, argv); + return 0; +} +``` +### if only use sequential tests +``` +int main(){ + run_all_tests(); + return 0; +} +``` +### if use only parrallel tests +``` +int main(){ + run_all_tests_parallel(4); /* to use 4 threads */ + return 0; +} +``` + +# FMOCK +## How to create fmock +outside all function: +``` +MOCK_FUNC(returnType, name_function_mock,(prototype of the function with paranthesis),(args when call the funct with parathesis)) +/* use (returnType) in parathesis if the returType has more than 1 words for example (long int) or (struct someStruct) */ +``` +For example, to create a function mock as signature: +``` +int f_mock(int a,int b); +``` +we use +``` +MOCK_FUNC(int, f_mock,(int a,int b),(a,b)) +``` +## print variables +We may define a function to print variables of the mock function, it is usefull in logs, the macro has almost the same args as MOCK_FUNC, without returnType wich is alway `char*`. +For example with `f_mock` we define: +``` +STR_PRINT_CUR_VAR(f_mock, (int a,int b),(a,b)){ + char *ret=malloc(150); + sprintf(ret,"(int)a: %d, (int)b: %d",a,b); + return ret; +} +``` +## define expect call +``` +EXPECT_MOCK_CALL(int, f_mock, (int a,int b), (a