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 #include <stdio.h>
   2 #include <stdbool.h>
   3 #include <glib.h>
   4 
   5 #include <crm_internal.h>
   6 
   7 static void
   8 empty_list(void)
     /* [previous][next][first][last][top][bottom][index][help] */
   9 {
  10     g_assert_cmpint(pcmk__char_in_any_str('x', NULL), ==, false);
  11     g_assert_cmpint(pcmk__char_in_any_str('\0', NULL), ==, false);
  12 }
  13 
  14 static void
  15 null_char(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  16 {
  17     g_assert_cmpint(pcmk__char_in_any_str('\0', "xxx", "yyy", NULL), ==, true);
  18     g_assert_cmpint(pcmk__char_in_any_str('\0', "", NULL), ==, true);
  19 }
  20 
  21 static void
  22 in_list(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  23 {
  24     g_assert_cmpint(pcmk__char_in_any_str('x', "aaa", "bbb", "xxx", NULL), ==, true);
  25 }
  26 
  27 static void
  28 not_in_list(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  29 {
  30     g_assert_cmpint(pcmk__char_in_any_str('x', "aaa", "bbb", NULL), ==, false);
  31     g_assert_cmpint(pcmk__char_in_any_str('A', "aaa", "bbb", NULL), ==, false);
  32     g_assert_cmpint(pcmk__char_in_any_str('x', "", NULL), ==, false);
  33 }
  34 
  35 int main(int argc, char **argv)
     /* [previous][next][first][last][top][bottom][index][help] */
  36 {
  37     g_test_init(&argc, &argv, NULL);
  38 
  39     g_test_add_func("/common/strings/char_in_any_str/empty_list", empty_list);
  40     g_test_add_func("/common/strings/char_in_any_str/null_char", null_char);
  41     g_test_add_func("/common/strings/char_in_any_str/in", in_list);
  42     g_test_add_func("/common/strings/char_in_any_str/not_in", not_in_list);
  43 
  44     return g_test_run();
  45 }
  46 

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