pacemaker 2.1.5-a3f44794f94
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 Lesser General Public License
7 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8 */
9
10#include <crm_internal.h>
11
13
14static void
15empty_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
21static void
22null_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
28static void
29in_list(void **state)
30{
31 assert_true(pcmk__char_in_any_str('x', "aaa", "bbb", "xxx", NULL));
32}
33
34static void
35not_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
42PCMK__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:975
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)