This source file includes following definitions.
- null_unknown
- invalid
- valid
- case_insensitive
1
2
3
4
5
6
7
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))