This source file includes following definitions.
- empty_input_list
- empty_string
- in_list
- not_in_list
- main
1 #include <stdio.h>
2 #include <stdbool.h>
3 #include <glib.h>
4
5 #include <crm_internal.h>
6
7 static void
8 empty_input_list(void) {
9 g_assert_cmpint(pcmk__strcase_any_of("xxx", NULL), ==, false);
10 g_assert_cmpint(pcmk__str_any_of("xxx", NULL), ==, false);
11 g_assert_cmpint(pcmk__strcase_any_of("", NULL), ==, false);
12 g_assert_cmpint(pcmk__str_any_of("", NULL), ==, false);
13 }
14
15 static void
16 empty_string(void) {
17 g_assert_cmpint(pcmk__strcase_any_of("", "xxx", "yyy", NULL), ==, false);
18 g_assert_cmpint(pcmk__str_any_of("", "xxx", "yyy", NULL), ==, false);
19 g_assert_cmpint(pcmk__strcase_any_of(NULL, "xxx", "yyy", NULL), ==, false);
20 g_assert_cmpint(pcmk__str_any_of(NULL, "xxx", "yyy", NULL), ==, false);
21 }
22
23 static void
24 in_list(void) {
25 g_assert_cmpint(pcmk__strcase_any_of("xxx", "aaa", "bbb", "xxx", NULL), ==, true);
26 g_assert_cmpint(pcmk__str_any_of("xxx", "aaa", "bbb", "xxx", NULL), ==, true);
27 g_assert_cmpint(pcmk__strcase_any_of("XXX", "aaa", "bbb", "xxx", NULL), ==, true);
28 }
29
30 static void
31 not_in_list(void) {
32 g_assert_cmpint(pcmk__strcase_any_of("xxx", "aaa", "bbb", NULL), ==, false);
33 g_assert_cmpint(pcmk__str_any_of("xxx", "aaa", "bbb", NULL), ==, false);
34 g_assert_cmpint(pcmk__str_any_of("AAA", "aaa", "bbb", NULL), ==, false);
35 }
36
37 int main(int argc, char **argv)
38 {
39 g_test_init(&argc, &argv, NULL);
40
41 g_test_add_func("/common/strings/any_of/empty_list", empty_input_list);
42 g_test_add_func("/common/strings/any_of/empty_string", empty_string);
43 g_test_add_func("/common/strings/any_of/in", in_list);
44 g_test_add_func("/common/strings/any_of/not_in", not_in_list);
45
46 return g_test_run();
47 }