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
  5. main

   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 <stdarg.h>
  13 #include <stddef.h>
  14 #include <stdint.h>
  15 #include <setjmp.h>
  16 #include <cmocka.h>
  17 
  18 static void
  19 empty_list(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  20 {
  21     assert_false(pcmk__char_in_any_str('x', NULL));
  22     assert_false(pcmk__char_in_any_str('\0', NULL));
  23 }
  24 
  25 static void
  26 null_char(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  27 {
  28     assert_true(pcmk__char_in_any_str('\0', "xxx", "yyy", NULL));
  29     assert_true(pcmk__char_in_any_str('\0', "", NULL));
  30 }
  31 
  32 static void
  33 in_list(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  34 {
  35     assert_true(pcmk__char_in_any_str('x', "aaa", "bbb", "xxx", NULL));
  36 }
  37 
  38 static void
  39 not_in_list(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  40 {
  41     assert_false(pcmk__char_in_any_str('x', "aaa", "bbb", NULL));
  42     assert_false(pcmk__char_in_any_str('A', "aaa", "bbb", NULL));
  43     assert_false(pcmk__char_in_any_str('x', "", NULL));
  44 }
  45 
  46 int main(int argc, char **argv)
     /* [previous][next][first][last][top][bottom][index][help] */
  47 {
  48     const struct CMUnitTest tests[] = {
  49         cmocka_unit_test(empty_list),
  50         cmocka_unit_test(null_char),
  51         cmocka_unit_test(in_list),
  52         cmocka_unit_test(not_in_list),
  53     };
  54 
  55     cmocka_set_message_output(CM_OUTPUT_TAP);
  56     return cmocka_run_group_tests(tests, NULL, NULL);
  57 }
  58 

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