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

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

DEFINITIONS

This source file includes following definitions.
  1. target_is_NULL
  2. src_is_NULL
  3. copying_is_successful

   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 Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) 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 target_is_NULL(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  18 {
  19     xmlNode *test_xml_1 = create_xml_node(NULL, "test_xml_1");
  20     xmlNode *test_xml_2 = NULL;
  21 
  22     pcmk__xe_set_props(test_xml_1, "test_prop", "test_value", NULL);
  23 
  24     copy_in_properties(test_xml_2, test_xml_1);
  25 
  26     assert_ptr_equal(test_xml_2, NULL);
  27 }
  28 
  29 static void
  30 src_is_NULL(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  31 {
  32     xmlNode *test_xml_1 = NULL;
  33     xmlNode *test_xml_2 = create_xml_node(NULL, "test_xml_2");
  34 
  35     copy_in_properties(test_xml_2, test_xml_1);
  36 
  37     assert_ptr_equal(test_xml_2->properties, NULL);
  38 }
  39 
  40 static void
  41 copying_is_successful(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  42 {
  43     const char *xml_1_value;
  44     const char *xml_2_value;
  45 
  46     xmlNode *test_xml_1 = create_xml_node(NULL, "test_xml_1");
  47     xmlNode *test_xml_2 = create_xml_node(NULL, "test_xml_2");
  48 
  49     pcmk__xe_set_props(test_xml_1, "test_prop", "test_value", NULL);
  50 
  51     copy_in_properties(test_xml_2, test_xml_1);
  52 
  53     xml_1_value = crm_element_value(test_xml_1, "test_prop");
  54     xml_2_value = crm_element_value(test_xml_2, "test_prop");
  55 
  56     assert_string_equal(xml_1_value, xml_2_value);
  57 }
  58 
  59 PCMK__UNIT_TEST(NULL, NULL,
  60                 cmocka_unit_test(target_is_NULL),
  61                 cmocka_unit_test(src_is_NULL),
  62                 cmocka_unit_test(copying_is_successful))

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