This source file includes following definitions.
- empty_input
- attr_missing
- attr_present
- main
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11 #include <crm/common/xml_internal.h>
12
13 #include <stdarg.h>
14 #include <stddef.h>
15 #include <stdint.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <setjmp.h>
19 #include <cmocka.h>
20
21 static void
22 empty_input(void **state)
23 {
24 xmlNode *node = string2xml("<node/>");
25
26 assert_false(pcmk__xe_attr_is_true(NULL, NULL));
27 assert_false(pcmk__xe_attr_is_true(NULL, "whatever"));
28 assert_false(pcmk__xe_attr_is_true(node, NULL));
29
30 free_xml(node);
31 }
32
33 static void
34 attr_missing(void **state)
35 {
36 xmlNode *node = string2xml("<node a=\"true\" b=\"false\"/>");
37
38 assert_false(pcmk__xe_attr_is_true(node, "c"));
39 free_xml(node);
40 }
41
42 static void
43 attr_present(void **state)
44 {
45 xmlNode *node = string2xml("<node a=\"true\" b=\"false\"/>");
46
47 assert_true(pcmk__xe_attr_is_true(node, "a"));
48 assert_false(pcmk__xe_attr_is_true(node, "b"));
49
50 free_xml(node);
51 }
52
53 int
54 main(int argc, char **argv)
55 {
56 const struct CMUnitTest tests[] = {
57 cmocka_unit_test(empty_input),
58 cmocka_unit_test(attr_missing),
59 cmocka_unit_test(attr_present),
60 };
61
62 cmocka_set_message_output(CM_OUTPUT_TAP);
63 return cmocka_run_group_tests(tests, NULL, NULL);
64 }