pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
pcmk__xe_set_bool_attr_test.c
Go to the documentation of this file.
1/*
2 * Copyright 2021-2024 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/common/xml.h>
15
16static void
17set_attr(void **state)
18{
19 xmlNode *node = pcmk__xml_parse("<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"), PCMK_VALUE_TRUE);
25 assert_string_equal(crm_element_value(node, "b"), PCMK_VALUE_FALSE);
26
27 pcmk__xml_free(node);
28}
29
31 cmocka_unit_test(set_attr))
#define PCMK_VALUE_TRUE
Definition options.h:219
#define PCMK_VALUE_FALSE
Definition options.h:154
int pcmk__xml_test_teardown_group(void **state)
Definition unittest.c:105
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
int pcmk__xml_test_setup_group(void **state)
Definition unittest.c:87
Wrappers for and extensions to libxml2.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
void pcmk__xe_set_bool_attr(xmlNodePtr node, const char *name, bool value)
void pcmk__xml_free(xmlNode *xml)
Definition xml.c:816
xmlNode * pcmk__xml_parse(const char *input)
Definition xml_io.c:167