def: Add missing cmocka_set_message_output symbol
[platform/upstream/cmocka.git] / tests / test_group_fixtures.c
1 /* Use the unit test allocators */
2 #define UNIT_TESTING 1
3
4 #include <stdarg.h>
5 #include <stddef.h>
6 #include <setjmp.h>
7 #include <cmocka.h>
8
9 static int group_setup(void **state)
10 {
11     int *answer = malloc(sizeof(int));
12     assert_non_null(answer);
13     *answer = 42;
14
15     *state = answer;
16     return 0;
17 }
18
19 static int group_teardown(void **state)
20 {
21     int *answer = (int *)*state;
22
23     free(answer);
24     return 0;
25 }
26
27 static void test_value_equal(void **state)
28 {
29     int a = *((int *)*state);
30
31     assert_int_equal(a, 42);
32 }
33
34 static void test_value_range(void **state)
35 {
36     int a = *((int *)*state);
37
38     assert_in_range(a, 0, 100);
39 }
40
41 int main(void) {
42     const struct CMUnitTest tests[] = {
43         cmocka_unit_test(test_value_equal),
44         cmocka_unit_test(test_value_range),
45     };
46
47     return cmocka_run_group_tests(tests, group_setup, group_teardown);
48 }