pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
pcmk__xe_set_bool_attr_test.c
Go to the documentation of this file.
1 /*
2  * Copyright 2021 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 
14 #include <crm/msg_xml.h>
15 
16 static void
17 set_attr(void **state)
18 {
19  xmlNode *node = string2xml("<node/>");
20 
21  pcmk__xe_set_bool_attr(node, "a", true);
22  pcmk__xe_set_bool_attr(node, "b", false);
23 
24  assert_string_equal(crm_element_value(node, "a"), XML_BOOLEAN_TRUE);
25  assert_string_equal(crm_element_value(node, "b"), XML_BOOLEAN_FALSE);
26 
27  free_xml(node);
28 }
29 
30 PCMK__UNIT_TEST(NULL, NULL,
31  cmocka_unit_test(set_attr))
#define XML_BOOLEAN_FALSE
Definition: msg_xml.h:168
void pcmk__xe_set_bool_attr(xmlNodePtr node, const char *name, bool value)
Definition: nvpair.c:872
PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(bad_input), cmocka_unit_test(not_found), cmocka_unit_test(find_attrB), cmocka_unit_test(find_attrA_matching))
xmlNode * string2xml(const char *input)
Definition: xml.c:800
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition: nvpair.c:447
#define XML_BOOLEAN_TRUE
Definition: msg_xml.h:167
void free_xml(xmlNode *child)
Definition: xml.c:783