pacemaker
2.1.9-49aab99839
Scalable High-Availability cluster resource manager
lib
common
tests
rules
pcmk__parse_comparison_test.c
Go to the documentation of this file.
1
/*
2
* Copyright 2024 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 <stdio.h>
13
14
#include <
crm/common/rules_internal.h
>
15
#include <
crm/common/unittest_internal.h
>
16
#include "
crmcommon_private.h
"
17
18
static
void
19
null_unknown(
void
**state)
20
{
21
assert_int_equal(
pcmk__parse_comparison
(NULL),
pcmk__comparison_unknown
);
22
}
23
24
static
void
25
invalid(
void
**state)
26
{
27
assert_int_equal(
pcmk__parse_comparison
(
"nope"
),
pcmk__comparison_unknown
);
28
}
29
30
static
void
31
valid(
void
**state)
32
{
33
assert_int_equal(
pcmk__parse_comparison
(
PCMK_VALUE_DEFINED
),
34
pcmk__comparison_defined
);
35
36
assert_int_equal(
pcmk__parse_comparison
(
PCMK_VALUE_NOT_DEFINED
),
37
pcmk__comparison_undefined
);
38
39
assert_int_equal(
pcmk__parse_comparison
(
PCMK_VALUE_EQ
),
40
pcmk__comparison_eq
);
41
42
assert_int_equal(
pcmk__parse_comparison
(
PCMK_VALUE_NE
),
43
pcmk__comparison_ne
);
44
45
assert_int_equal(
pcmk__parse_comparison
(
PCMK_VALUE_LT
),
46
pcmk__comparison_lt
);
47
48
assert_int_equal(
pcmk__parse_comparison
(
PCMK_VALUE_LTE
),
49
pcmk__comparison_lte
);
50
51
assert_int_equal(
pcmk__parse_comparison
(
PCMK_VALUE_GT
),
52
pcmk__comparison_gt
);
53
54
assert_int_equal(
pcmk__parse_comparison
(
PCMK_VALUE_GTE
),
55
pcmk__comparison_gte
);
56
}
57
58
static
void
59
case_insensitive(
void
**state)
60
{
61
assert_int_equal(
pcmk__parse_comparison
(
"DEFINED"
),
62
pcmk__comparison_defined
);
63
64
assert_int_equal(
pcmk__parse_comparison
(
"Not_Defined"
),
65
pcmk__comparison_undefined
);
66
}
67
68
PCMK__UNIT_TEST
(NULL, NULL,
69
cmocka_unit_test(null_unknown),
70
cmocka_unit_test(invalid),
71
cmocka_unit_test(valid),
72
cmocka_unit_test(case_insensitive))
rules_internal.h
PCMK_VALUE_NOT_DEFINED
#define PCMK_VALUE_NOT_DEFINED
Definition:
options.h:180
pcmk__comparison_lte
Definition:
crmcommon_private.h:349
PCMK__UNIT_TEST
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
Definition:
unittest_internal.h:188
PCMK_VALUE_EQ
#define PCMK_VALUE_EQ
Definition:
options.h:149
pcmk__comparison_eq
Definition:
crmcommon_private.h:346
PCMK_VALUE_LTE
#define PCMK_VALUE_LTE
Definition:
options.h:167
crm_internal.h
pcmk__comparison_defined
Definition:
crmcommon_private.h:344
PCMK_VALUE_GTE
#define PCMK_VALUE_GTE
Definition:
options.h:159
pcmk__comparison_gt
Definition:
crmcommon_private.h:350
pcmk__comparison_lt
Definition:
crmcommon_private.h:348
pcmk__comparison_ne
Definition:
crmcommon_private.h:347
pcmk__comparison_undefined
Definition:
crmcommon_private.h:345
crmcommon_private.h
unittest_internal.h
PCMK_VALUE_GT
#define PCMK_VALUE_GT
Definition:
options.h:158
PCMK_VALUE_LT
#define PCMK_VALUE_LT
Definition:
options.h:166
pcmk__parse_comparison
G_GNUC_INTERNAL enum pcmk__comparison pcmk__parse_comparison(const char *op)
Definition:
rules.c:724
PCMK_VALUE_NE
#define PCMK_VALUE_NE
Definition:
options.h:176
PCMK_VALUE_DEFINED
#define PCMK_VALUE_DEFINED
Definition:
options.h:143
pcmk__comparison_gte
Definition:
crmcommon_private.h:351
pcmk__comparison_unknown
Definition:
crmcommon_private.h:343
Generated on Thu Oct 31 2024 15:49:03 for pacemaker by
1.8.14