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
  6. main

   1 #include <stdio.h>
   2 #include <stdbool.h>
   3 #include <glib.h>
   4 
   5 #include <crm_internal.h>
   6 
   7 static void
   8 uppercase_str_passes(void)
     /* [previous][next][first][last][top][bottom][index][help] */
   9 {
  10     g_assert_cmpint(pcmk_str_is_infinity("INFINITY"), ==, true);
  11     g_assert_cmpint(pcmk_str_is_infinity("+INFINITY"), ==, true);
  12 }
  13 
  14 static void
  15 mixed_case_str_fails(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  16 {
  17     g_assert_cmpint(pcmk_str_is_infinity("infinity"), ==, false);
  18     g_assert_cmpint(pcmk_str_is_infinity("+infinity"), ==, false);
  19     g_assert_cmpint(pcmk_str_is_infinity("Infinity"), ==, false);
  20     g_assert_cmpint(pcmk_str_is_infinity("+Infinity"), ==, false);
  21 }
  22 
  23 static void
  24 added_whitespace_fails(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  25 {
  26     g_assert_cmpint(pcmk_str_is_infinity(" INFINITY"), ==, false);
  27     g_assert_cmpint(pcmk_str_is_infinity("INFINITY "), ==, false);
  28     g_assert_cmpint(pcmk_str_is_infinity(" INFINITY "), ==, false);
  29     g_assert_cmpint(pcmk_str_is_infinity("+ INFINITY"), ==, false);
  30 }
  31 
  32 static void
  33 empty_str_fails(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  34 {
  35     g_assert_cmpint(pcmk_str_is_infinity(NULL), ==, false);
  36     g_assert_cmpint(pcmk_str_is_infinity(""), ==, false);
  37 }
  38 
  39 static void
  40 minus_infinity_fails(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  41 {
  42     g_assert_cmpint(pcmk_str_is_infinity("-INFINITY"), ==, false);
  43 }
  44 
  45 int main(int argc, char **argv)
     /* [previous][next][first][last][top][bottom][index][help] */
  46 {
  47     g_test_init(&argc, &argv, NULL);
  48 
  49     g_test_add_func("/common/utils/infinity/uppercase", uppercase_str_passes);
  50     g_test_add_func("/common/utils/infinity/mixed_case", mixed_case_str_fails);
  51     g_test_add_func("/common/utils/infinity/whitespace", added_whitespace_fails);
  52     g_test_add_func("/common/utils/infinity/empty", empty_str_fails);
  53     g_test_add_func("/common/utils/infinity/minus_infinity", minus_infinity_fails);
  54 
  55     return g_test_run();
  56 }

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