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

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