pacemaker  3.0.0-d8340737c4
Scalable High-Availability cluster resource manager
pcmk__timeout_ms2s_test.c
Go to the documentation of this file.
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 
13 
14 static void
15 pcmk__timeout_ms2s_test(void **state)
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))
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
guint pcmk__timeout_ms2s(guint timeout_ms)
Definition: utils.c:425