pacemaker  2.1.9-49aab99839
Scalable High-Availability cluster resource manager
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 
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 {
35 
38 
39  assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_EQ),
41 
42  assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_NE),
44 
45  assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_LT),
47 
48  assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_LTE),
50 
51  assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_GT),
53 
54  assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_GTE),
56 }
57 
58 static void
59 case_insensitive(void **state)
60 {
61  assert_int_equal(pcmk__parse_comparison("DEFINED"),
63 
64  assert_int_equal(pcmk__parse_comparison("Not_Defined"),
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))
#define PCMK_VALUE_NOT_DEFINED
Definition: options.h:180
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
#define PCMK_VALUE_EQ
Definition: options.h:149
#define PCMK_VALUE_LTE
Definition: options.h:167
#define PCMK_VALUE_GTE
Definition: options.h:159
#define PCMK_VALUE_GT
Definition: options.h:158
#define PCMK_VALUE_LT
Definition: options.h:166
G_GNUC_INTERNAL enum pcmk__comparison pcmk__parse_comparison(const char *op)
Definition: rules.c:724
#define PCMK_VALUE_NE
Definition: options.h:176
#define PCMK_VALUE_DEFINED
Definition: options.h:143