pacemaker
2.0.5-ba59be7122
Scalable High-Availability cluster resource manager
lib
common
tests
strings
pcmk__str_any_of_test.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <stdbool.h>
3
#include <glib.h>
4
5
#include <
crm_internal.h
>
6
7
static
void
8
empty_input_list(
void
) {
9
g_assert_cmpint(
pcmk__strcase_any_of
(
"xxx"
, NULL), ==,
false
);
10
g_assert_cmpint(
pcmk__str_any_of
(
"xxx"
, NULL), ==,
false
);
11
g_assert_cmpint(
pcmk__strcase_any_of
(
""
, NULL), ==,
false
);
12
g_assert_cmpint(
pcmk__str_any_of
(
""
, NULL), ==,
false
);
13
}
14
15
static
void
16
empty_string(
void
) {
17
g_assert_cmpint(
pcmk__strcase_any_of
(
""
,
"xxx"
,
"yyy"
, NULL), ==,
false
);
18
g_assert_cmpint(
pcmk__str_any_of
(
""
,
"xxx"
,
"yyy"
, NULL), ==,
false
);
19
g_assert_cmpint(
pcmk__strcase_any_of
(NULL,
"xxx"
,
"yyy"
, NULL), ==,
false
);
20
g_assert_cmpint(
pcmk__str_any_of
(NULL,
"xxx"
,
"yyy"
, NULL), ==,
false
);
21
}
22
23
static
void
24
in_list(
void
) {
25
g_assert_cmpint(
pcmk__strcase_any_of
(
"xxx"
,
"aaa"
,
"bbb"
,
"xxx"
, NULL), ==,
true
);
26
g_assert_cmpint(
pcmk__str_any_of
(
"xxx"
,
"aaa"
,
"bbb"
,
"xxx"
, NULL), ==,
true
);
27
g_assert_cmpint(
pcmk__strcase_any_of
(
"XXX"
,
"aaa"
,
"bbb"
,
"xxx"
, NULL), ==,
true
);
28
}
29
30
static
void
31
not_in_list(
void
) {
32
g_assert_cmpint(
pcmk__strcase_any_of
(
"xxx"
,
"aaa"
,
"bbb"
, NULL), ==,
false
);
33
g_assert_cmpint(
pcmk__str_any_of
(
"xxx"
,
"aaa"
,
"bbb"
, NULL), ==,
false
);
34
g_assert_cmpint(
pcmk__str_any_of
(
"AAA"
,
"aaa"
,
"bbb"
, NULL), ==,
false
);
35
}
36
37
int
main
(
int
argc,
char
**argv)
38
{
39
g_test_init(&argc, &argv, NULL);
40
41
g_test_add_func(
"/common/strings/any_of/empty_list"
, empty_input_list);
42
g_test_add_func(
"/common/strings/any_of/empty_string"
, empty_string);
43
g_test_add_func(
"/common/strings/any_of/in"
, in_list);
44
g_test_add_func(
"/common/strings/any_of/not_in"
, not_in_list);
45
46
return
g_test_run();
47
}
main
int main(int argc, char **argv)
Definition:
pcmk__str_any_of_test.c:37
pcmk__str_any_of
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
Definition:
strings.c:866
pcmk__strcase_any_of
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
Definition:
strings.c:842
crm_internal.h
Generated on Fri Jan 8 2021 18:47:14 for pacemaker by
1.8.20