pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
pcmk__str_any_of_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_input_list(void **state) {
16  assert_false(pcmk__strcase_any_of("xxx", NULL));
17  assert_false(pcmk__str_any_of("xxx", NULL));
18  assert_false(pcmk__strcase_any_of("", NULL));
19  assert_false(pcmk__str_any_of("", NULL));
20 }
21 
22 static void
23 empty_string(void **state) {
24  assert_false(pcmk__strcase_any_of("", "xxx", "yyy", NULL));
25  assert_false(pcmk__str_any_of("", "xxx", "yyy", NULL));
26  assert_false(pcmk__strcase_any_of(NULL, "xxx", "yyy", NULL));
27  assert_false(pcmk__str_any_of(NULL, "xxx", "yyy", NULL));
28 }
29 
30 static void
31 in_list(void **state) {
32  assert_true(pcmk__strcase_any_of("xxx", "aaa", "bbb", "xxx", NULL));
33  assert_true(pcmk__str_any_of("xxx", "aaa", "bbb", "xxx", NULL));
34  assert_true(pcmk__strcase_any_of("XXX", "aaa", "bbb", "xxx", NULL));
35 }
36 
37 static void
38 not_in_list(void **state) {
39  assert_false(pcmk__strcase_any_of("xxx", "aaa", "bbb", NULL));
40  assert_false(pcmk__str_any_of("xxx", "aaa", "bbb", NULL));
41  assert_false(pcmk__str_any_of("AAA", "aaa", "bbb", NULL));
42 }
43 
44 PCMK__UNIT_TEST(NULL, NULL,
45  cmocka_unit_test(empty_input_list),
46  cmocka_unit_test(empty_string),
47  cmocka_unit_test(in_list),
48  cmocka_unit_test(not_in_list))
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
Definition: strings.c:933
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))
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
Definition: strings.c:957