pacemaker 2.1.4-dc6eb4362e
Scalable High-Availability cluster resource manager
score2char_test.c
Go to the documentation of this file.
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
18static void
19outside_limits(void **state)
20{
21 char *a = NULL;
22
24 assert_string_equal(a, CRM_INFINITY_S);
25 free(a);
26
28 assert_string_equal(a, CRM_MINUS_INFINITY_S);
29 free(a);
30}
31
32static void
33inside_limits(void **state)
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
50int main(int argc, char **argv)
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}
char * score2char(int score)
Return the string equivalent of an integer score.
Definition: scores.c:114
#define CRM_SCORE_INFINITY
Definition: crm.h:85
#define CRM_INFINITY_S
Definition: crm.h:86
#define CRM_MINUS_INFINITY_S
Definition: crm.h:88
int main(int argc, char **argv)