cmocka: fix doxygen comment for assert_in_range()
[obnox/cmocka.git] / tests / test_setup_fail.c
1 #define UNIT_TESTING 1
2
3 #include <stdarg.h>
4 #include <stddef.h>
5 #include <setjmp.h>
6 #include <cmocka.h>
7
8 static void setup_fail(void **state) {
9     *state = NULL;
10
11     /* We need to fail in setup */
12     assert_non_null(NULL);
13 }
14
15 static void int_test_ignored(void **state) {
16     /* should not be called */
17     assert_non_null(*state);
18 }
19
20 static void setup_ok(void **state) {
21     int *answer = malloc(sizeof(int));
22
23     assert_non_null(answer);
24     *answer = 42;
25
26     *state = answer;
27 }
28
29 /* A test case that does check if an int is equal. */
30 static void int_test_success(void **state) {
31     int *answer = *state;
32
33     assert_int_equal(*answer, 42);
34 }
35
36 static void teardown(void **state) {
37     free(*state);
38 }
39
40 int main(void) {
41     const UnitTest tests[] = {
42         unit_test_setup_teardown(int_test_ignored, setup_fail, teardown),
43         unit_test_setup_teardown(int_test_success, setup_ok, teardown),
44     };
45
46     return run_tests(tests);
47 }