pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
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
14static void
15empty_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
22static void
23empty_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
30static void
31in_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
37static void
38not_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
44PCMK__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:1029
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
Definition strings.c:1053
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)