This source file includes following definitions.
- empty_input_list
- empty_string
- 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_input_list(void **state) {
20 assert_false(pcmk__strcase_any_of("xxx", NULL));
21 assert_false(pcmk__str_any_of("xxx", NULL));
22 assert_false(pcmk__strcase_any_of("", NULL));
23 assert_false(pcmk__str_any_of("", NULL));
24 }
25
26 static void
27 empty_string(void **state) {
28 assert_false(pcmk__strcase_any_of("", "xxx", "yyy", NULL));
29 assert_false(pcmk__str_any_of("", "xxx", "yyy", NULL));
30 assert_false(pcmk__strcase_any_of(NULL, "xxx", "yyy", NULL));
31 assert_false(pcmk__str_any_of(NULL, "xxx", "yyy", NULL));
32 }
33
34 static void
35 in_list(void **state) {
36 assert_true(pcmk__strcase_any_of("xxx", "aaa", "bbb", "xxx", NULL));
37 assert_true(pcmk__str_any_of("xxx", "aaa", "bbb", "xxx", NULL));
38 assert_true(pcmk__strcase_any_of("XXX", "aaa", "bbb", "xxx", NULL));
39 }
40
41 static void
42 not_in_list(void **state) {
43 assert_false(pcmk__strcase_any_of("xxx", "aaa", "bbb", NULL));
44 assert_false(pcmk__str_any_of("xxx", "aaa", "bbb", NULL));
45 assert_false(pcmk__str_any_of("AAA", "aaa", "bbb", NULL));
46 }
47
48 int main(int argc, char **argv)
49 {
50 const struct CMUnitTest tests[] = {
51 cmocka_unit_test(empty_input_list),
52 cmocka_unit_test(empty_string),
53 cmocka_unit_test(in_list),
54 cmocka_unit_test(not_in_list),
55 };
56
57 cmocka_set_message_output(CM_OUTPUT_TAP);
58 return cmocka_run_group_tests(tests, NULL, NULL);
59 }