This source file includes following definitions.
- empty_list
- null_char
- in_list
- not_in_list
- main
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <stdarg.h>
13 #include <stddef.h>
14 #include <stdint.h>
15 #include <setjmp.h>
16 #include <cmocka.h>
17
18 static void
19 empty_list(void **state)
20 {
21 assert_false(pcmk__char_in_any_str('x', NULL));
22 assert_false(pcmk__char_in_any_str('\0', NULL));
23 }
24
25 static void
26 null_char(void **state)
27 {
28 assert_true(pcmk__char_in_any_str('\0', "xxx", "yyy", NULL));
29 assert_true(pcmk__char_in_any_str('\0', "", NULL));
30 }
31
32 static void
33 in_list(void **state)
34 {
35 assert_true(pcmk__char_in_any_str('x', "aaa", "bbb", "xxx", NULL));
36 }
37
38 static void
39 not_in_list(void **state)
40 {
41 assert_false(pcmk__char_in_any_str('x', "aaa", "bbb", NULL));
42 assert_false(pcmk__char_in_any_str('A', "aaa", "bbb", NULL));
43 assert_false(pcmk__char_in_any_str('x', "", NULL));
44 }
45
46 int main(int argc, char **argv)
47 {
48 const struct CMUnitTest tests[] = {
49 cmocka_unit_test(empty_list),
50 cmocka_unit_test(null_char),
51 cmocka_unit_test(in_list),
52 cmocka_unit_test(not_in_list),
53 };
54
55 cmocka_set_message_output(CM_OUTPUT_TAP);
56 return cmocka_run_group_tests(tests, NULL, NULL);
57 }
58