This source file includes following definitions.
- uppercase_str_passes
- mixed_case_str_fails
- added_whitespace_fails
- empty_str_fails
- minus_infinity_fails
- main
1 #include <stdio.h>
2 #include <stdbool.h>
3 #include <glib.h>
4
5 #include <crm_internal.h>
6
7 static void
8 uppercase_str_passes(void)
9 {
10 g_assert_cmpint(pcmk_str_is_infinity("INFINITY"), ==, true);
11 g_assert_cmpint(pcmk_str_is_infinity("+INFINITY"), ==, true);
12 }
13
14 static void
15 mixed_case_str_fails(void)
16 {
17 g_assert_cmpint(pcmk_str_is_infinity("infinity"), ==, false);
18 g_assert_cmpint(pcmk_str_is_infinity("+infinity"), ==, false);
19 g_assert_cmpint(pcmk_str_is_infinity("Infinity"), ==, false);
20 g_assert_cmpint(pcmk_str_is_infinity("+Infinity"), ==, false);
21 }
22
23 static void
24 added_whitespace_fails(void)
25 {
26 g_assert_cmpint(pcmk_str_is_infinity(" INFINITY"), ==, false);
27 g_assert_cmpint(pcmk_str_is_infinity("INFINITY "), ==, false);
28 g_assert_cmpint(pcmk_str_is_infinity(" INFINITY "), ==, false);
29 g_assert_cmpint(pcmk_str_is_infinity("+ INFINITY"), ==, false);
30 }
31
32 static void
33 empty_str_fails(void)
34 {
35 g_assert_cmpint(pcmk_str_is_infinity(NULL), ==, false);
36 g_assert_cmpint(pcmk_str_is_infinity(""), ==, false);
37 }
38
39 static void
40 minus_infinity_fails(void)
41 {
42 g_assert_cmpint(pcmk_str_is_infinity("-INFINITY"), ==, false);
43 }
44
45 int main(int argc, char **argv)
46 {
47 g_test_init(&argc, &argv, NULL);
48
49 g_test_add_func("/common/utils/infinity/uppercase", uppercase_str_passes);
50 g_test_add_func("/common/utils/infinity/mixed_case", mixed_case_str_fails);
51 g_test_add_func("/common/utils/infinity/whitespace", added_whitespace_fails);
52 g_test_add_func("/common/utils/infinity/empty", empty_str_fails);
53 g_test_add_func("/common/utils/infinity/minus_infinity", minus_infinity_fails);
54
55 return g_test_run();
56 }