pacemaker
2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
lib
common
tests
strings
crm_is_true_test.c
Go to the documentation of this file.
1
/*
2
* Copyright 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
12
#include <
crm/common/unittest_internal.h
>
13
14
static
void
15
bad_input(
void
**state) {
16
assert_false(
crm_is_true
(NULL));
17
}
18
19
static
void
20
is_true(
void
**state) {
21
assert_true(
crm_is_true
(
"true"
));
22
assert_true(
crm_is_true
(
"TrUe"
));
23
assert_true(
crm_is_true
(
"on"
));
24
assert_true(
crm_is_true
(
"ON"
));
25
assert_true(
crm_is_true
(
"yes"
));
26
assert_true(
crm_is_true
(
"yES"
));
27
assert_true(
crm_is_true
(
"y"
));
28
assert_true(
crm_is_true
(
"Y"
));
29
assert_true(
crm_is_true
(
"1"
));
30
}
31
32
static
void
33
is_false(
void
**state) {
34
assert_false(
crm_is_true
(
"false"
));
35
assert_false(
crm_is_true
(
"fAlSe"
));
36
assert_false(
crm_is_true
(
"off"
));
37
assert_false(
crm_is_true
(
"OFF"
));
38
assert_false(
crm_is_true
(
"no"
));
39
assert_false(
crm_is_true
(
"No"
));
40
assert_false(
crm_is_true
(
"n"
));
41
assert_false(
crm_is_true
(
"N"
));
42
assert_false(
crm_is_true
(
"0"
));
43
44
assert_false(
crm_is_true
(
""
));
45
assert_false(
crm_is_true
(
"blahblah"
));
46
47
assert_false(
crm_is_true
(
"truedat"
));
48
assert_false(
crm_is_true
(
"onnn"
));
49
assert_false(
crm_is_true
(
"yep"
));
50
assert_false(
crm_is_true
(
"Y!"
));
51
assert_false(
crm_is_true
(
"100"
));
52
}
53
54
PCMK__UNIT_TEST
(NULL, NULL,
55
cmocka_unit_test(bad_input),
56
cmocka_unit_test(is_true),
57
cmocka_unit_test(is_false))
PCMK__UNIT_TEST
PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(bad_input), cmocka_unit_test(not_found), cmocka_unit_test(find_attrB), cmocka_unit_test(find_attrA_matching))
crm_internal.h
unittest_internal.h
crm_is_true
gboolean crm_is_true(const char *s)
Definition:
strings.c:416
Generated on Tue Dec 19 2023 17:32:56 for pacemaker by
1.8.14