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

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

DEFINITIONS

This source file includes following definitions.
  1. bad_input
  2. starts_with

   1 /*
   2  * Copyright 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 bad_input(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  16     assert_false(pcmk__starts_with(NULL, "x"));
  17     assert_false(pcmk__starts_with("abc", NULL));
  18 }
  19 
  20 static void
  21 starts_with(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  22     assert_true(pcmk__starts_with("abc", "a"));
  23     assert_true(pcmk__starts_with("abc", "ab"));
  24     assert_true(pcmk__starts_with("abc", "abc"));
  25 
  26     assert_false(pcmk__starts_with("abc", "A"));
  27     assert_false(pcmk__starts_with("abc", "bc"));
  28 
  29     assert_false(pcmk__starts_with("", "x"));
  30     assert_true(pcmk__starts_with("xyz", ""));
  31 }
  32 
  33 PCMK__UNIT_TEST(NULL, NULL,
  34                 cmocka_unit_test(bad_input),
  35                 cmocka_unit_test(starts_with))

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