pacemaker  2.0.5-ba59be712
Scalable High-Availability cluster resource manager
pcmk__char_in_any_str_test.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdbool.h>
3 #include <glib.h>
4 
5 #include <crm_internal.h>
6 
7 static void
8 empty_list(void)
9 {
10  g_assert_cmpint(pcmk__char_in_any_str('x', NULL), ==, false);
11  g_assert_cmpint(pcmk__char_in_any_str('\0', NULL), ==, false);
12 }
13 
14 static void
15 null_char(void)
16 {
17  g_assert_cmpint(pcmk__char_in_any_str('\0', "xxx", "yyy", NULL), ==, true);
18  g_assert_cmpint(pcmk__char_in_any_str('\0', "", NULL), ==, true);
19 }
20 
21 static void
22 in_list(void)
23 {
24  g_assert_cmpint(pcmk__char_in_any_str('x', "aaa", "bbb", "xxx", NULL), ==, true);
25 }
26 
27 static void
28 not_in_list(void)
29 {
30  g_assert_cmpint(pcmk__char_in_any_str('x', "aaa", "bbb", NULL), ==, false);
31  g_assert_cmpint(pcmk__char_in_any_str('A', "aaa", "bbb", NULL), ==, false);
32  g_assert_cmpint(pcmk__char_in_any_str('x', "", NULL), ==, false);
33 }
34 
35 int main(int argc, char **argv)
36 {
37  g_test_init(&argc, &argv, NULL);
38 
39  g_test_add_func("/common/strings/char_in_any_str/empty_list", empty_list);
40  g_test_add_func("/common/strings/char_in_any_str/null_char", null_char);
41  g_test_add_func("/common/strings/char_in_any_str/in", in_list);
42  g_test_add_func("/common/strings/char_in_any_str/not_in", not_in_list);
43 
44  return g_test_run();
45 }
46 
bool pcmk__char_in_any_str(int ch,...) G_GNUC_NULL_TERMINATED
Definition: strings.c:889
int main(int argc, char **argv)