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

   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 General Public License version 2
   7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <crm_internal.h>
  11 
  12 #include <crm/common/unittest_internal.h>
  13 
  14 static void
  15 empty_input_list(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  16     assert_false(pcmk__strcase_any_of("xxx", NULL));
  17     assert_false(pcmk__str_any_of("xxx", NULL));
  18     assert_false(pcmk__strcase_any_of("", NULL));
  19     assert_false(pcmk__str_any_of("", NULL));
  20 }
  21 
  22 static void
  23 empty_string(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  24     assert_false(pcmk__strcase_any_of("", "xxx", "yyy", NULL));
  25     assert_false(pcmk__str_any_of("", "xxx", "yyy", NULL));
  26     assert_false(pcmk__strcase_any_of(NULL, "xxx", "yyy", NULL));
  27     assert_false(pcmk__str_any_of(NULL, "xxx", "yyy", NULL));
  28 }
  29 
  30 static void
  31 in_list(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  32     assert_true(pcmk__strcase_any_of("xxx", "aaa", "bbb", "xxx", NULL));
  33     assert_true(pcmk__str_any_of("xxx", "aaa", "bbb", "xxx", NULL));
  34     assert_true(pcmk__strcase_any_of("XXX", "aaa", "bbb", "xxx", NULL));
  35 }
  36 
  37 static void
  38 not_in_list(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  39     assert_false(pcmk__strcase_any_of("xxx", "aaa", "bbb", NULL));
  40     assert_false(pcmk__str_any_of("xxx", "aaa", "bbb", NULL));
  41     assert_false(pcmk__str_any_of("AAA", "aaa", "bbb", NULL));
  42 }
  43 
  44 PCMK__UNIT_TEST(NULL, NULL,
  45                 cmocka_unit_test(empty_input_list),
  46                 cmocka_unit_test(empty_string),
  47                 cmocka_unit_test(in_list),
  48                 cmocka_unit_test(not_in_list))

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