root/lib/common/tests/nvpair/pcmk__xe_set_bool_attr_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. set_attr
  2. main

   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 Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <crm_internal.h>
  11 #include <crm/common/xml_internal.h>
  12 #include <crm/msg_xml.h>
  13 
  14 #include <stdarg.h>
  15 #include <stddef.h>
  16 #include <stdint.h>
  17 #include <stdlib.h>
  18 #include <string.h>
  19 #include <setjmp.h>
  20 #include <cmocka.h>
  21 
  22 static void
  23 set_attr(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  24 {
  25     xmlNode *node = string2xml("<node/>");
  26 
  27     pcmk__xe_set_bool_attr(node, "a", true);
  28     pcmk__xe_set_bool_attr(node, "b", false);
  29 
  30     assert_string_equal(crm_element_value(node, "a"), XML_BOOLEAN_TRUE);
  31     assert_string_equal(crm_element_value(node, "b"), XML_BOOLEAN_FALSE);
  32 
  33     free_xml(node);
  34 }
  35 
  36 int
  37 main(int argc, char **argv)
     /* [previous][next][first][last][top][bottom][index][help] */
  38 {
  39     const struct CMUnitTest tests[] = {
  40         cmocka_unit_test(set_attr),
  41     };
  42 
  43     cmocka_set_message_output(CM_OUTPUT_TAP);
  44     return cmocka_run_group_tests(tests, NULL, NULL);
  45 }

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