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

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

DEFINITIONS

This source file includes following definitions.
  1. default_and
  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 
  17 static void
  18 default_and(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  19 {
  20     assert_int_equal(pcmk__parse_combine(NULL), pcmk__combine_and);
  21 }
  22 
  23 static void
  24 invalid(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  25 {
  26     assert_int_equal(pcmk__parse_combine(""), pcmk__combine_unknown);
  27     assert_int_equal(pcmk__parse_combine(" "), pcmk__combine_unknown);
  28     assert_int_equal(pcmk__parse_combine("but"), pcmk__combine_unknown);
  29 }
  30 
  31 static void
  32 valid(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  33 {
  34     assert_int_equal(pcmk__parse_combine(PCMK_VALUE_AND), pcmk__combine_and);
  35     assert_int_equal(pcmk__parse_combine(PCMK_VALUE_OR), pcmk__combine_or);
  36 }
  37 
  38 static void
  39 case_insensitive(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  40 {
  41     assert_int_equal(pcmk__parse_combine("And"),
  42                      pcmk__combine_and);
  43 
  44     assert_int_equal(pcmk__parse_combine("OR"),
  45                      pcmk__combine_or);
  46 }
  47 
  48 PCMK__UNIT_TEST(NULL, NULL,
  49                 cmocka_unit_test(default_and),
  50                 cmocka_unit_test(invalid),
  51                 cmocka_unit_test(valid),
  52                 cmocka_unit_test(case_insensitive))

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