root/lib/common/tests/strings/pcmk__char_in_any_str_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. empty_list
  2. null_char
  3. in_list
  4. not_in_list

   1 /*
   2  * Copyright 2020-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 
  14 static void
  15 empty_list(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  16 {
  17     assert_false(pcmk__char_in_any_str('x', NULL));
  18     assert_false(pcmk__char_in_any_str('\0', NULL));
  19 }
  20 
  21 static void
  22 null_char(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  23 {
  24     assert_true(pcmk__char_in_any_str('\0', "xxx", "yyy", NULL));
  25     assert_true(pcmk__char_in_any_str('\0', "", NULL));
  26 }
  27 
  28 static void
  29 in_list(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  30 {
  31     assert_true(pcmk__char_in_any_str('x', "aaa", "bbb", "xxx", NULL));
  32 }
  33 
  34 static void
  35 not_in_list(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  36 {
  37     assert_false(pcmk__char_in_any_str('x', "aaa", "bbb", NULL));
  38     assert_false(pcmk__char_in_any_str('A', "aaa", "bbb", NULL));
  39     assert_false(pcmk__char_in_any_str('x', "", NULL));
  40 }
  41 
  42 PCMK__UNIT_TEST(NULL, NULL,
  43                 cmocka_unit_test(empty_list),
  44                 cmocka_unit_test(null_char),
  45                 cmocka_unit_test(in_list),
  46                 cmocka_unit_test(not_in_list))

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