pacemaker
2.1.1-52dc28db4
Scalable High-Availability cluster resource manager
lib
common
tests
strings
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
12
#include <stdio.h>
13
#include <stdbool.h>
14
#include <glib.h>
15
16
static
void
17
empty_list(
void
)
18
{
19
g_assert_false(
pcmk__char_in_any_str
(
'x'
, NULL));
20
g_assert_false(
pcmk__char_in_any_str
(
'\0'
, NULL));
21
}
22
23
static
void
24
null_char(
void
)
25
{
26
g_assert_true(
pcmk__char_in_any_str
(
'\0'
,
"xxx"
,
"yyy"
, NULL));
27
g_assert_true(
pcmk__char_in_any_str
(
'\0'
,
""
, NULL));
28
}
29
30
static
void
31
in_list(
void
)
32
{
33
g_assert_true(
pcmk__char_in_any_str
(
'x'
,
"aaa"
,
"bbb"
,
"xxx"
, NULL));
34
}
35
36
static
void
37
not_in_list(
void
)
38
{
39
g_assert_false(
pcmk__char_in_any_str
(
'x'
,
"aaa"
,
"bbb"
, NULL));
40
g_assert_false(
pcmk__char_in_any_str
(
'A'
,
"aaa"
,
"bbb"
, NULL));
41
g_assert_false(
pcmk__char_in_any_str
(
'x'
,
""
, NULL));
42
}
43
44
int
main
(
int
argc,
char
**argv)
45
{
46
g_test_init(&argc, &argv, NULL);
47
48
g_test_add_func(
"/common/strings/char_in_any_str/empty_list"
, empty_list);
49
g_test_add_func(
"/common/strings/char_in_any_str/null_char"
, null_char);
50
g_test_add_func(
"/common/strings/char_in_any_str/in"
, in_list);
51
g_test_add_func(
"/common/strings/char_in_any_str/not_in"
, not_in_list);
52
53
return
g_test_run();
54
}
55
pcmk__char_in_any_str
bool pcmk__char_in_any_str(int ch,...) G_GNUC_NULL_TERMINATED
Definition:
strings.c:1002
crm_internal.h
main
int main(int argc, char **argv)
Definition:
pcmk__char_in_any_str_test.c:44
Generated on Fri Sep 10 2021 09:15:59 for pacemaker by
1.8.14