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 <stdio.h>
13 #include <stdbool.h>
14 #include <glib.h>
15
16 static void
17 empty_input_list(void) {
18 g_assert_false(pcmk__strcase_any_of("xxx", NULL));
19 g_assert_false(pcmk__str_any_of("xxx", NULL));
20 g_assert_false(pcmk__strcase_any_of("", NULL));
21 g_assert_false(pcmk__str_any_of("", NULL));
22 }
23
24 static void
25 empty_string(void) {
26 g_assert_false(pcmk__strcase_any_of("", "xxx", "yyy", NULL));
27 g_assert_false(pcmk__str_any_of("", "xxx", "yyy", NULL));
28 g_assert_false(pcmk__strcase_any_of(NULL, "xxx", "yyy", NULL));
29 g_assert_false(pcmk__str_any_of(NULL, "xxx", "yyy", NULL));
30 }
31
32 static void
33 in_list(void) {
34 g_assert_true(pcmk__strcase_any_of("xxx", "aaa", "bbb", "xxx", NULL));
35 g_assert_true(pcmk__str_any_of("xxx", "aaa", "bbb", "xxx", NULL));
36 g_assert_true(pcmk__strcase_any_of("XXX", "aaa", "bbb", "xxx", NULL));
37 }
38
39 static void
40 not_in_list(void) {
41 g_assert_false(pcmk__strcase_any_of("xxx", "aaa", "bbb", NULL));
42 g_assert_false(pcmk__str_any_of("xxx", "aaa", "bbb", NULL));
43 g_assert_false(pcmk__str_any_of("AAA", "aaa", "bbb", NULL));
44 }
45
46 int main(int argc, char **argv)
47 {
48 g_test_init(&argc, &argv, NULL);
49
50 g_test_add_func("/common/strings/any_of/empty_list", empty_input_list);
51 g_test_add_func("/common/strings/any_of/empty_string", empty_string);
52 g_test_add_func("/common/strings/any_of/in", in_list);
53 g_test_add_func("/common/strings/any_of/not_in", not_in_list);
54
55 return g_test_run();
56 }