diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2021-02-13 03:08:53 +0100 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2021-02-13 03:08:53 +0100 |
commit | 9ce6b70090d3ddf6842f833923ae08ae1d9042dd (patch) | |
tree | 0ae6824c79e0dee13c2d81624f7e8711332acde0 | |
parent | ffc4c9b6b9e6cb7a5c6f3481aa7c303a010b6869 (diff) | |
download | mtest-9ce6b70090d3ddf6842f833923ae08ae1d9042dd.tar.gz mtest-9ce6b70090d3ddf6842f833923ae08ae1d9042dd.tar.bz2 mtest-9ce6b70090d3ddf6842f833923ae08ae1d9042dd.zip |
man: document new mt_run_quick() macro
Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
-rw-r--r-- | man/mt_run.3 | 49 | ||||
-rw-r--r-- | man/mt_run_quick.3 | 1 | ||||
-rw-r--r-- | man/mt_run_quick_named.3 | 1 |
3 files changed, 51 insertions, 0 deletions
diff --git a/man/mt_run.3 b/man/mt_run.3 index e679bd0..6107353 100644 --- a/man/mt_run.3 +++ b/man/mt_run.3 @@ -20,6 +20,10 @@ c/c++ .BI "mt_run_named(" function_name ", " test_name ")" .br .BI "mt_run_param_named(" function_name_param ", " parameter ", " test_name ")" +.br +.BI "mt_run_quick(" expression ")" +.br +.BI "mt_run_quick_named(" expression ", " test_name ")" .PP .BI "static void (*" mt_prepare_test ")(void)" .br @@ -80,6 +84,51 @@ program, when you want to pass parameter with spaces, you need to use double quotes like .BR """'parameter\ with\ spaces'""" . .PP +.BR mt_run_quick (3) +allows to perform quick test with only single +.I expression +check. +It initializes tests with +.IR mt_prepare_test and mt_cleanup_test +but does only single +.BR mt_fail (3) +on +.IR expresssion . +This is effectively same as doing +.PP +.EX + void foo(void) { mt_fail(e); } + void test_group(void) { mt_run(foo); } +.EE +.PP +Now, of course you could simply do multiple +.BR mt_fail (3) +calls but with that you loose some context, especially with +.BR mt_run_quick_named (3) +variant of the function. +.PP +.BR mt_run_quick_named (3) +works in the same way as +.BR mt_run_quick (3) +but also allows to specify custom test name for better test analysis. +Like said before, it is better to use this instead of multiple +.BR mt_fail (3) +checks to get some more context. +.PP +.EX + /* It is easier to see what broke if you use it like */ + void test_group(void) { + mt_run(foo_init(arg1) == 0, "foo_init should succeed"); + mt_run(foo_init(NULL) == -1, "foo_init should fail when arg1 = NULL"); + } + + /* instead of doing */ + void foo_init_tests(void) { + mt_fail(foo_init(arg1) == 0); + mt_fail(foo_init(NULL) == -1); + } +.EE +.PP Optionally user can also set two function pointers .I mt_prepare_test and diff --git a/man/mt_run_quick.3 b/man/mt_run_quick.3 new file mode 100644 index 0000000..7c9fe17 --- /dev/null +++ b/man/mt_run_quick.3 @@ -0,0 +1 @@ +.so man3/mt_run.3 diff --git a/man/mt_run_quick_named.3 b/man/mt_run_quick_named.3 new file mode 100644 index 0000000..7c9fe17 --- /dev/null +++ b/man/mt_run_quick_named.3 @@ -0,0 +1 @@ +.so man3/mt_run.3 |