root/lib/common/tests/utils/crm_meta_value_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. empty_params
  2. key_not_in_table
  3. key_in_table

   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 #include <crm/msg_xml.h>
  14 
  15 #include <glib.h>
  16 
  17 static void
  18 empty_params(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  19 {
  20     GHashTable *tbl = pcmk__strkey_table(free, free);
  21 
  22     assert_null(crm_meta_value(NULL, NULL));
  23     assert_null(crm_meta_value(tbl, NULL));
  24 
  25     g_hash_table_destroy(tbl);
  26 }
  27 
  28 static void
  29 key_not_in_table(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  30 {
  31     GHashTable *tbl = pcmk__strkey_table(free, free);
  32 
  33     assert_null(crm_meta_value(tbl, XML_RSC_ATTR_NOTIFY));
  34     assert_null(crm_meta_value(tbl, XML_RSC_ATTR_STICKINESS));
  35 
  36     g_hash_table_destroy(tbl);
  37 }
  38 
  39 static void
  40 key_in_table(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  41 {
  42     GHashTable *tbl = pcmk__strkey_table(free, free);
  43 
  44     g_hash_table_insert(tbl, crm_meta_name(XML_RSC_ATTR_NOTIFY), strdup("1"));
  45     g_hash_table_insert(tbl, crm_meta_name(XML_RSC_ATTR_STICKINESS), strdup("2"));
  46 
  47     assert_string_equal(crm_meta_value(tbl, XML_RSC_ATTR_NOTIFY), "1");
  48     assert_string_equal(crm_meta_value(tbl, XML_RSC_ATTR_STICKINESS), "2");
  49 
  50     g_hash_table_destroy(tbl);
  51 }
  52 
  53 PCMK__UNIT_TEST(NULL, NULL,
  54                 cmocka_unit_test(empty_params),
  55                 cmocka_unit_test(key_not_in_table),
  56                 cmocka_unit_test(key_in_table))

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