This source file includes following definitions.
- element_nodes
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/unittest_internal.h>
13
14 #include <glib.h>
15
16 static void
17 element_nodes(void **state)
18 {
19 const char *new_value_root;
20 const char *new_value_child;
21 const char *new_value_grandchild;
22
23 xmlNode *test_xml_root = create_xml_node(NULL, "test_xml_root");
24 xmlNode *test_xml_child = create_xml_node(test_xml_root, "test_xml_child");
25 xmlNode *test_xml_grandchild = create_xml_node(test_xml_child, "test_xml_grandchild");
26 xmlNode *test_xml_text = pcmk_create_xml_text_node(test_xml_root, "text_xml_text", "content");
27 xmlNode *test_xml_comment = string2xml("<!-- a comment -->");
28
29 crm_xml_add(test_xml_root, "X", "5");
30 crm_xml_add(test_xml_child, "X", "X++");
31 crm_xml_add(test_xml_grandchild, "X", "X+=2");
32 crm_xml_add(test_xml_text, "X", "X++");
33
34 fix_plus_plus_recursive(test_xml_root);
35 fix_plus_plus_recursive(test_xml_comment);
36
37 new_value_root = crm_element_value(test_xml_root, "X");
38 new_value_child = crm_element_value(test_xml_child, "X");
39 new_value_grandchild = crm_element_value(test_xml_grandchild, "X");
40
41 assert_string_equal(new_value_root, "5");
42 assert_string_equal(new_value_child, "1");
43 assert_string_equal(new_value_grandchild, "2");
44 }
45
46 PCMK__UNIT_TEST(NULL, NULL,
47 cmocka_unit_test(element_nodes))