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

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

DEFINITIONS

This source file includes following definitions.
  1. empty_input_list
  2. empty_string
  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_input_list(void) {
     /* [previous][next][first][last][top][bottom][index][help] */
  18     g_assert_false(pcmk__strcase_any_of("xxx", NULL));
  19     g_assert_false(pcmk__str_any_of("xxx", NULL));
  20     g_assert_false(pcmk__strcase_any_of("", NULL));
  21     g_assert_false(pcmk__str_any_of("", NULL));
  22 }
  23 
  24 static void
  25 empty_string(void) {
     /* [previous][next][first][last][top][bottom][index][help] */
  26     g_assert_false(pcmk__strcase_any_of("", "xxx", "yyy", NULL));
  27     g_assert_false(pcmk__str_any_of("", "xxx", "yyy", NULL));
  28     g_assert_false(pcmk__strcase_any_of(NULL, "xxx", "yyy", NULL));
  29     g_assert_false(pcmk__str_any_of(NULL, "xxx", "yyy", NULL));
  30 }
  31 
  32 static void
  33 in_list(void) {
     /* [previous][next][first][last][top][bottom][index][help] */
  34     g_assert_true(pcmk__strcase_any_of("xxx", "aaa", "bbb", "xxx", NULL));
  35     g_assert_true(pcmk__str_any_of("xxx", "aaa", "bbb", "xxx", NULL));
  36     g_assert_true(pcmk__strcase_any_of("XXX", "aaa", "bbb", "xxx", NULL));
  37 }
  38 
  39 static void
  40 not_in_list(void) {
     /* [previous][next][first][last][top][bottom][index][help] */
  41     g_assert_false(pcmk__strcase_any_of("xxx", "aaa", "bbb", NULL));
  42     g_assert_false(pcmk__str_any_of("xxx", "aaa", "bbb", NULL));
  43     g_assert_false(pcmk__str_any_of("AAA", "aaa", "bbb", NULL));
  44 }
  45 
  46 int main(int argc, char **argv)
     /* [previous][next][first][last][top][bottom][index][help] */
  47 {
  48     g_test_init(&argc, &argv, NULL);
  49 
  50     g_test_add_func("/common/strings/any_of/empty_list", empty_input_list);
  51     g_test_add_func("/common/strings/any_of/empty_string", empty_string);
  52     g_test_add_func("/common/strings/any_of/in", in_list);
  53     g_test_add_func("/common/strings/any_of/not_in", not_in_list);
  54 
  55     return g_test_run();
  56 }

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