diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2012-10-15 20:37:36 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2012-10-15 20:43:34 +0200 |
commit | 4752bd5620919447a9844ee1565c75e38a4a5629 (patch) | |
tree | e424af1e3a4f29783a7aaea435bf8e528bbd08ac /doc | |
parent | df7de3b0b4434e1223240a9f2f5fad03a4a15f59 (diff) | |
download | cmocka-4752bd5620919447a9844ee1565c75e38a4a5629.tar.gz cmocka-4752bd5620919447a9844ee1565c75e38a4a5629.tar.bz2 cmocka-4752bd5620919447a9844ee1565c75e38a4a5629.zip |
doc: Add example for cmocka test case.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/mainpage.dox | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/mainpage.dox b/doc/mainpage.dox index 76d6500..0e2664b 100644 --- a/doc/mainpage.dox +++ b/doc/mainpage.dox @@ -42,4 +42,33 @@ The CMocka library provides: TODO Explain mock objects. +@section main-test A CMocka test + +CMocka unit test cases are functions with the signature void function(void **state). +CMocka test applications initialize a table with test case function pointers +using unit_test() macros. This table is then passed to the run_tests() macro to +execute the tests. run_tests() sets up the appropriate exception / signal +handlers and other data structures prior to running each test function. When a +unit test is complete run_tests() performs various checks to determine whether +the test succeeded. + +@code +#include <stdarg.h> +#include <stddef.h> +#include <setjmp.h> +#include <cmockery.h> + +/* A test case that does nothing and succeeds. */ +void null_test_success(void **state) { +} + +int main(void) { + const UnitTest tests[] = { + unit_test(null_test_success), + }; + + return run_tests(tests); +} +@endcode + */ |