pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
pcmk__char_in_any_str_test.c
Go to the documentation of this file.
1 /*
2  * Copyright 2020-2021 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU General Public License version 2
7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
8  */
9 
10 #include <crm_internal.h>
11 
13 
14 static void
15 empty_list(void **state)
16 {
17  assert_false(pcmk__char_in_any_str('x', NULL));
18  assert_false(pcmk__char_in_any_str('\0', NULL));
19 }
20 
21 static void
22 null_char(void **state)
23 {
24  assert_true(pcmk__char_in_any_str('\0', "xxx", "yyy", NULL));
25  assert_true(pcmk__char_in_any_str('\0', "", NULL));
26 }
27 
28 static void
29 in_list(void **state)
30 {
31  assert_true(pcmk__char_in_any_str('x', "aaa", "bbb", "xxx", NULL));
32 }
33 
34 static void
35 not_in_list(void **state)
36 {
37  assert_false(pcmk__char_in_any_str('x', "aaa", "bbb", NULL));
38  assert_false(pcmk__char_in_any_str('A', "aaa", "bbb", NULL));
39  assert_false(pcmk__char_in_any_str('x', "", NULL));
40 }
41 
42 PCMK__UNIT_TEST(NULL, NULL,
43  cmocka_unit_test(empty_list),
44  cmocka_unit_test(null_char),
45  cmocka_unit_test(in_list),
46  cmocka_unit_test(not_in_list))
bool pcmk__char_in_any_str(int ch,...) G_GNUC_NULL_TERMINATED
Definition: strings.c:980
PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(bad_input), cmocka_unit_test(not_found), cmocka_unit_test(find_attrB), cmocka_unit_test(find_attrA_matching))