pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
pcmk__xe_attr_is_true_test.c
Go to the documentation of this file.
1/*
2 * Copyright 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
15static void
16empty_input(void **state)
17{
18 xmlNode *node = pcmk__xml_parse("<node/>");
19
20 assert_false(pcmk__xe_attr_is_true(NULL, NULL));
21 assert_false(pcmk__xe_attr_is_true(NULL, "whatever"));
22 assert_false(pcmk__xe_attr_is_true(node, NULL));
23
24 pcmk__xml_free(node);
25}
26
27static void
28attr_missing(void **state)
29{
30 xmlNode *node = pcmk__xml_parse("<node a=\"true\" b=\"false\"/>");
31
32 assert_false(pcmk__xe_attr_is_true(node, "c"));
33 pcmk__xml_free(node);
34}
35
36static void
37attr_present(void **state)
38{
39 xmlNode *node = pcmk__xml_parse("<node a=\"true\" b=\"false\"/>");
40
41 assert_true(pcmk__xe_attr_is_true(node, "a"));
42 assert_false(pcmk__xe_attr_is_true(node, "b"));
43
44 pcmk__xml_free(node);
45}
46
48 cmocka_unit_test(empty_input),
49 cmocka_unit_test(attr_missing),
50 cmocka_unit_test(attr_present))
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
bool pcmk__xe_attr_is_true(const xmlNode *node, const char *name)
void pcmk__xml_free(xmlNode *xml)
Definition xml.c:816
xmlNode * pcmk__xml_parse(const char *input)
Definition xml_io.c:167