root/lib/common/tests/scores/score2char_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. outside_limits
  2. inside_limits
  3. main

   1 /*
   2  * Copyright 2022 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 outside_limits(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  20 {
  21     char *a = NULL;
  22 
  23     a = score2char(CRM_SCORE_INFINITY * 2);
  24     assert_string_equal(a, CRM_INFINITY_S);
  25     free(a);
  26 
  27     a = score2char(-CRM_SCORE_INFINITY * 2);
  28     assert_string_equal(a, CRM_MINUS_INFINITY_S);
  29     free(a);
  30 }
  31 
  32 static void
  33 inside_limits(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  34 {
  35     char *a = NULL;
  36 
  37     a = score2char(1024);
  38     assert_string_equal(a, "1024");
  39     free(a);
  40 
  41     a = score2char(0);
  42     assert_string_equal(a, "0");
  43     free(a);
  44 
  45     a = score2char(-1024);
  46     assert_string_equal(a, "-1024");
  47     free(a);
  48 }
  49 
  50 int main(int argc, char **argv)
     /* [previous][next][first][last][top][bottom][index][help] */
  51 {
  52     const struct CMUnitTest tests[] = {
  53         cmocka_unit_test(outside_limits),
  54         cmocka_unit_test(inside_limits),
  55     };
  56 
  57     cmocka_set_message_output(CM_OUTPUT_TAP);
  58     return cmocka_run_group_tests(tests, NULL, NULL);
  59 }

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