pacemaker  2.1.8-3980678f03
Scalable High-Availability cluster resource manager
pcmk_readable_score_test.c
Go to the documentation of this file.
1 /*
2  * Copyright 2022-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 outside_limits(void **state)
16 {
17  assert_string_equal(pcmk_readable_score(PCMK_SCORE_INFINITY * 2),
19  assert_string_equal(pcmk_readable_score(-PCMK_SCORE_INFINITY * 2),
21 }
22 
23 static void
24 inside_limits(void **state)
25 {
26  assert_string_equal(pcmk_readable_score(0), "0");
27  assert_string_equal(pcmk_readable_score(1024), "1024");
28  assert_string_equal(pcmk_readable_score(-1024), "-1024");
29 }
30 
31 PCMK__UNIT_TEST(NULL, NULL,
32  cmocka_unit_test(outside_limits),
33  cmocka_unit_test(inside_limits))
#define PCMK_VALUE_MINUS_INFINITY
Definition: options.h:173
#define PCMK_VALUE_INFINITY
Definition: options.h:163
const char * pcmk_readable_score(int score)
Return a displayable static string for a score value.
Definition: scores.c:86
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
#define PCMK_SCORE_INFINITY
Integer score to use to represent "infinity".
Definition: scores.h:24