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

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

DEFINITIONS

This source file includes following definitions.
  1. null_unknown
  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 null_unknown(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  20 {
  21     assert_int_equal(pcmk__parse_comparison(NULL), pcmk__comparison_unknown);
  22 }
  23 
  24 static void
  25 invalid(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  26 {
  27     assert_int_equal(pcmk__parse_comparison("nope"), pcmk__comparison_unknown);
  28 }
  29 
  30 static void
  31 valid(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  32 {
  33     assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_DEFINED),
  34                      pcmk__comparison_defined);
  35 
  36     assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_NOT_DEFINED),
  37                      pcmk__comparison_undefined);
  38 
  39     assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_EQ),
  40                      pcmk__comparison_eq);
  41 
  42     assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_NE),
  43                      pcmk__comparison_ne);
  44 
  45     assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_LT),
  46                      pcmk__comparison_lt);
  47 
  48     assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_LTE),
  49                      pcmk__comparison_lte);
  50 
  51     assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_GT),
  52                      pcmk__comparison_gt);
  53 
  54     assert_int_equal(pcmk__parse_comparison(PCMK_VALUE_GTE),
  55                      pcmk__comparison_gte);
  56 }
  57 
  58 static void
  59 case_insensitive(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  60 {
  61     assert_int_equal(pcmk__parse_comparison("DEFINED"),
  62                      pcmk__comparison_defined);
  63 
  64     assert_int_equal(pcmk__parse_comparison("Not_Defined"),
  65                      pcmk__comparison_undefined);
  66 }
  67 
  68 PCMK__UNIT_TEST(NULL, NULL,
  69                 cmocka_unit_test(null_unknown),
  70                 cmocka_unit_test(invalid),
  71                 cmocka_unit_test(valid),
  72                 cmocka_unit_test(case_insensitive))

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