root/lib/common/tests/utils/pcmk_str_is_infinity_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. uppercase_str_passes
  2. mixed_case_str_fails
  3. added_whitespace_fails
  4. empty_str_fails
  5. minus_infinity_fails

   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 <crm/common/unittest_internal.h>
  13 
  14 static void
  15 uppercase_str_passes(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  16 {
  17     assert_true(pcmk_str_is_infinity("INFINITY"));
  18     assert_true(pcmk_str_is_infinity("+INFINITY"));
  19 }
  20 
  21 static void
  22 mixed_case_str_fails(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  23 {
  24     assert_false(pcmk_str_is_infinity("infinity"));
  25     assert_false(pcmk_str_is_infinity("+infinity"));
  26     assert_false(pcmk_str_is_infinity("Infinity"));
  27     assert_false(pcmk_str_is_infinity("+Infinity"));
  28 }
  29 
  30 static void
  31 added_whitespace_fails(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  32 {
  33     assert_false(pcmk_str_is_infinity(" INFINITY"));
  34     assert_false(pcmk_str_is_infinity("INFINITY "));
  35     assert_false(pcmk_str_is_infinity(" INFINITY "));
  36     assert_false(pcmk_str_is_infinity("+ INFINITY"));
  37 }
  38 
  39 static void
  40 empty_str_fails(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  41 {
  42     assert_false(pcmk_str_is_infinity(NULL));
  43     assert_false(pcmk_str_is_infinity(""));
  44 }
  45 
  46 static void
  47 minus_infinity_fails(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  48 {
  49     assert_false(pcmk_str_is_infinity("-INFINITY"));
  50 }
  51 
  52 PCMK__UNIT_TEST(NULL, NULL,
  53                 cmocka_unit_test(uppercase_str_passes),
  54                 cmocka_unit_test(mixed_case_str_fails),
  55                 cmocka_unit_test(added_whitespace_fails),
  56                 cmocka_unit_test(empty_str_fails),
  57                 cmocka_unit_test(minus_infinity_fails))

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