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

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

DEFINITIONS

This source file includes following definitions.
  1. pcmk__timeout_ms2s_test

   1 /*
   2  * Copyright 2024 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 pcmk__timeout_ms2s_test(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  16 {
  17     assert_int_equal(0, pcmk__timeout_ms2s(0));
  18 
  19     /* Any non-zero amount should return 1 */
  20     assert_int_equal(1, pcmk__timeout_ms2s(1));
  21     assert_int_equal(1, pcmk__timeout_ms2s(499));
  22     assert_int_equal(1, pcmk__timeout_ms2s(500));
  23     assert_int_equal(1, pcmk__timeout_ms2s(501));
  24 
  25     assert_int_equal(1, pcmk__timeout_ms2s(1001));
  26     assert_int_equal(1, pcmk__timeout_ms2s(1499));
  27     assert_int_equal(2, pcmk__timeout_ms2s(1500));
  28     assert_int_equal(2, pcmk__timeout_ms2s(1501));
  29 }
  30 
  31 PCMK__UNIT_TEST(NULL, NULL,
  32                 cmocka_unit_test(pcmk__timeout_ms2s_test))

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