This source file includes following definitions.
- outside_limits
- inside_limits
- main
1
2
3
4
5
6
7
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)
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)
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)
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 }