This source file includes following definitions.
- default_literal
- 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 default_literal(void **state)
20 {
21 assert_int_equal(pcmk__parse_source(NULL), pcmk__source_literal);
22 }
23
24 static void
25 invalid(void **state)
26 {
27 assert_int_equal(pcmk__parse_source(""), pcmk__source_unknown);
28 assert_int_equal(pcmk__parse_source(" "), pcmk__source_unknown);
29 assert_int_equal(pcmk__parse_source("params"), pcmk__source_unknown);
30 }
31
32 static void
33 valid(void **state)
34 {
35 assert_int_equal(pcmk__parse_source(PCMK_VALUE_LITERAL),
36 pcmk__source_literal);
37
38 assert_int_equal(pcmk__parse_source(PCMK_VALUE_PARAM),
39 pcmk__source_instance_attrs);
40
41 assert_int_equal(pcmk__parse_source(PCMK_VALUE_META),
42 pcmk__source_meta_attrs);
43 }
44
45 static void
46 case_insensitive(void **state)
47 {
48 assert_int_equal(pcmk__parse_source("LITERAL"),
49 pcmk__source_literal);
50
51 assert_int_equal(pcmk__parse_source("Param"),
52 pcmk__source_instance_attrs);
53
54 assert_int_equal(pcmk__parse_source("MeTa"),
55 pcmk__source_meta_attrs);
56 }
57
58 PCMK__UNIT_TEST(NULL, NULL,
59 cmocka_unit_test(default_literal),
60 cmocka_unit_test(invalid),
61 cmocka_unit_test(valid),
62 cmocka_unit_test(case_insensitive))