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 <stdio.h>
  13 #include <stdbool.h>
  14 #include <glib.h>
  15 
  16 static void
  17 empty_list(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  18 {
  19     g_assert_false(pcmk__char_in_any_str('x', NULL));
  20     g_assert_false(pcmk__char_in_any_str('\0', NULL));
  21 }
  22 
  23 static void
  24 null_char(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  25 {
  26     g_assert_true(pcmk__char_in_any_str('\0', "xxx", "yyy", NULL));
  27     g_assert_true(pcmk__char_in_any_str('\0', "", NULL));
  28 }
  29 
  30 static void
  31 in_list(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  32 {
  33     g_assert_true(pcmk__char_in_any_str('x', "aaa", "bbb", "xxx", NULL));
  34 }
  35 
  36 static void
  37 not_in_list(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  38 {
  39     g_assert_false(pcmk__char_in_any_str('x', "aaa", "bbb", NULL));
  40     g_assert_false(pcmk__char_in_any_str('A', "aaa", "bbb", NULL));
  41     g_assert_false(pcmk__char_in_any_str('x', "", NULL));
  42 }
  43 
  44 int main(int argc, char **argv)
     /* [previous][next][first][last][top][bottom][index][help] */
  45 {
  46     g_test_init(&argc, &argv, NULL);
  47 
  48     g_test_add_func("/common/strings/char_in_any_str/empty_list", empty_list);
  49     g_test_add_func("/common/strings/char_in_any_str/null_char", null_char);
  50     g_test_add_func("/common/strings/char_in_any_str/in", in_list);
  51     g_test_add_func("/common/strings/char_in_any_str/not_in", not_in_list);
  52 
  53     return g_test_run();
  54 }
  55 

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