root/lib/common/tests/operations/fix_plus_plus_recursive_test.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. element_nodes

   1 /*
   2  * Copyright 2022 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 
  12 #include <crm/common/unittest_internal.h>
  13 
  14 #include <glib.h>
  15 
  16 static void
  17 element_nodes(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  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))

/* [previous][next][first][last][top][bottom][index][help] */