root/lib/common/tests/rules/pcmk__parse_source_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. default_literal
  2. invalid
  3. valid
  4. case_insensitive

   1 /*
   2  * Copyright 2024 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 <stdio.h>
  13 
  14 #include <crm/common/rules_internal.h>
  15 #include <crm/common/unittest_internal.h>
  16 #include "crmcommon_private.h"
  17 
  18 static void
  19 default_literal(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  20 {
  21     assert_int_equal(pcmk__parse_source(NULL), pcmk__source_literal);
  22 }
  23 
  24 static void
  25 invalid(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  26 {
  27     assert_int_equal(pcmk__parse_source(""), pcmk__source_unknown);
  28     assert_int_equal(pcmk__parse_source(" "), pcmk__source_unknown);
  29     assert_int_equal(pcmk__parse_source("params"), pcmk__source_unknown);
  30 }
  31 
  32 static void
  33 valid(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  34 {
  35     assert_int_equal(pcmk__parse_source(PCMK_VALUE_LITERAL),
  36                      pcmk__source_literal);
  37 
  38     assert_int_equal(pcmk__parse_source(PCMK_VALUE_PARAM),
  39                      pcmk__source_instance_attrs);
  40 
  41     assert_int_equal(pcmk__parse_source(PCMK_VALUE_META),
  42                      pcmk__source_meta_attrs);
  43 }
  44 
  45 static void
  46 case_insensitive(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  47 {
  48     assert_int_equal(pcmk__parse_source("LITERAL"),
  49                      pcmk__source_literal);
  50 
  51     assert_int_equal(pcmk__parse_source("Param"),
  52                      pcmk__source_instance_attrs);
  53 
  54     assert_int_equal(pcmk__parse_source("MeTa"),
  55                      pcmk__source_meta_attrs);
  56 }
  57 
  58 PCMK__UNIT_TEST(NULL, NULL,
  59                 cmocka_unit_test(default_literal),
  60                 cmocka_unit_test(invalid),
  61                 cmocka_unit_test(valid),
  62                 cmocka_unit_test(case_insensitive))

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