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

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

DEFINITIONS

This source file includes following definitions.
  1. empty_input
  2. attr_missing
  3. attr_present

   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 
  12 #include <crm/common/unittest_internal.h>
  13 #include <crm/common/xml_internal.h>
  14 
  15 static void
  16 empty_input(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  17 {
  18     xmlNode *node = string2xml("<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     free_xml(node);
  25 }
  26 
  27 static void
  28 attr_missing(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  29 {
  30     xmlNode *node = string2xml("<node a=\"true\" b=\"false\"/>");
  31 
  32     assert_false(pcmk__xe_attr_is_true(node, "c"));
  33     free_xml(node);
  34 }
  35 
  36 static void
  37 attr_present(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  38 {
  39     xmlNode *node = string2xml("<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     free_xml(node);
  45 }
  46 
  47 PCMK__UNIT_TEST(NULL, NULL,
  48                 cmocka_unit_test(empty_input),
  49                 cmocka_unit_test(attr_missing),
  50                 cmocka_unit_test(attr_present))

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