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
  6. 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 <stdarg.h>
  13 #include <stddef.h>
  14 #include <stdint.h>
  15 #include <setjmp.h>
  16 #include <cmocka.h>
  17 
  18 static void
  19 uppercase_str_passes(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  20 {
  21     assert_true(pcmk_str_is_minus_infinity("-INFINITY"));
  22 }
  23 
  24 static void
  25 mixed_case_str_fails(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  26 {
  27     assert_false(pcmk_str_is_minus_infinity("-infinity"));
  28     assert_false(pcmk_str_is_minus_infinity("-Infinity"));
  29 }
  30 
  31 static void
  32 added_whitespace_fails(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  33 {
  34     assert_false(pcmk_str_is_minus_infinity(" -INFINITY"));
  35     assert_false(pcmk_str_is_minus_infinity("-INFINITY "));
  36     assert_false(pcmk_str_is_minus_infinity(" -INFINITY "));
  37     assert_false(pcmk_str_is_minus_infinity("- INFINITY"));
  38 }
  39 
  40 static void
  41 empty_str_fails(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  42 {
  43     assert_false(pcmk_str_is_minus_infinity(NULL));
  44     assert_false(pcmk_str_is_minus_infinity(""));
  45 }
  46 
  47 static void
  48 infinity_fails(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  49 {
  50     assert_false(pcmk_str_is_minus_infinity("INFINITY"));
  51 }
  52 
  53 int main(int argc, char **argv)
     /* [previous][next][first][last][top][bottom][index][help] */
  54 {
  55     const struct CMUnitTest tests[] = {
  56         cmocka_unit_test(uppercase_str_passes),
  57         cmocka_unit_test(mixed_case_str_fails),
  58         cmocka_unit_test(added_whitespace_fails),
  59         cmocka_unit_test(empty_str_fails),
  60         cmocka_unit_test(infinity_fails),
  61     };
  62 
  63     cmocka_set_message_output(CM_OUTPUT_TAP);
  64     return cmocka_run_group_tests(tests, NULL, NULL);
  65 }

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