This source file includes following definitions.
- uppercase_str_passes
- mixed_case_str_fails
- added_whitespace_fails
- empty_str_fails
- minus_infinity_fails
- 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 uppercase_str_passes(void **state)
20 {
21 assert_true(pcmk_str_is_infinity("INFINITY"));
22 assert_true(pcmk_str_is_infinity("+INFINITY"));
23 }
24
25 static void
26 mixed_case_str_fails(void **state)
27 {
28 assert_false(pcmk_str_is_infinity("infinity"));
29 assert_false(pcmk_str_is_infinity("+infinity"));
30 assert_false(pcmk_str_is_infinity("Infinity"));
31 assert_false(pcmk_str_is_infinity("+Infinity"));
32 }
33
34 static void
35 added_whitespace_fails(void **state)
36 {
37 assert_false(pcmk_str_is_infinity(" INFINITY"));
38 assert_false(pcmk_str_is_infinity("INFINITY "));
39 assert_false(pcmk_str_is_infinity(" INFINITY "));
40 assert_false(pcmk_str_is_infinity("+ INFINITY"));
41 }
42
43 static void
44 empty_str_fails(void **state)
45 {
46 assert_false(pcmk_str_is_infinity(NULL));
47 assert_false(pcmk_str_is_infinity(""));
48 }
49
50 static void
51 minus_infinity_fails(void **state)
52 {
53 assert_false(pcmk_str_is_infinity("-INFINITY"));
54 }
55
56 int main(int argc, char **argv)
57 {
58 const struct CMUnitTest tests[] = {
59 cmocka_unit_test(uppercase_str_passes),
60 cmocka_unit_test(mixed_case_str_fails),
61 cmocka_unit_test(added_whitespace_fails),
62 cmocka_unit_test(empty_str_fails),
63 cmocka_unit_test(minus_infinity_fails),
64 };
65
66 cmocka_set_message_output(CM_OUTPUT_TAP);
67 return cmocka_run_group_tests(tests, NULL, NULL);
68 }