pacemaker
2.1.1-52dc28db4
Scalable High-Availability cluster resource manager
lib
common
tests
utils
pcmk_str_is_infinity_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
uppercase_str_passes(
void
)
18
{
19
g_assert_true(
pcmk_str_is_infinity
(
"INFINITY"
));
20
g_assert_true(
pcmk_str_is_infinity
(
"+INFINITY"
));
21
}
22
23
static
void
24
mixed_case_str_fails(
void
)
25
{
26
g_assert_false(
pcmk_str_is_infinity
(
"infinity"
));
27
g_assert_false(
pcmk_str_is_infinity
(
"+infinity"
));
28
g_assert_false(
pcmk_str_is_infinity
(
"Infinity"
));
29
g_assert_false(
pcmk_str_is_infinity
(
"+Infinity"
));
30
}
31
32
static
void
33
added_whitespace_fails(
void
)
34
{
35
g_assert_false(
pcmk_str_is_infinity
(
" INFINITY"
));
36
g_assert_false(
pcmk_str_is_infinity
(
"INFINITY "
));
37
g_assert_false(
pcmk_str_is_infinity
(
" INFINITY "
));
38
g_assert_false(
pcmk_str_is_infinity
(
"+ INFINITY"
));
39
}
40
41
static
void
42
empty_str_fails(
void
)
43
{
44
g_assert_false(
pcmk_str_is_infinity
(NULL));
45
g_assert_false(
pcmk_str_is_infinity
(
""
));
46
}
47
48
static
void
49
minus_infinity_fails(
void
)
50
{
51
g_assert_false(
pcmk_str_is_infinity
(
"-INFINITY"
));
52
}
53
54
int
main
(
int
argc,
char
**argv)
55
{
56
g_test_init(&argc, &argv, NULL);
57
58
g_test_add_func(
"/common/utils/infinity/uppercase"
, uppercase_str_passes);
59
g_test_add_func(
"/common/utils/infinity/mixed_case"
, mixed_case_str_fails);
60
g_test_add_func(
"/common/utils/infinity/whitespace"
, added_whitespace_fails);
61
g_test_add_func(
"/common/utils/infinity/empty"
, empty_str_fails);
62
g_test_add_func(
"/common/utils/infinity/minus_infinity"
, minus_infinity_fails);
63
64
return
g_test_run();
65
}
crm_internal.h
pcmk_str_is_infinity
bool pcmk_str_is_infinity(const char *s)
Definition:
utils.c:585
main
int main(int argc, char **argv)
Definition:
pcmk_str_is_infinity_test.c:54
Generated on Fri Sep 10 2021 09:15:59 for pacemaker by
1.8.14