pacemaker  2.0.4-2deceaa
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pcmk_str_is_infinity.c
Go to the documentation of this file.
1 #include <glib.h>
2 
3 #include <crm_internal.h>
4 
5 static void
6 uppercase_str_passes(void) {
7  g_assert(pcmk_str_is_infinity("INFINITY") == TRUE);
8  g_assert(pcmk_str_is_infinity("+INFINITY") == TRUE);
9 }
10 
11 static void
12 mixed_case_str_fails(void) {
13  g_assert(pcmk_str_is_infinity("infinity") == FALSE);
14  g_assert(pcmk_str_is_infinity("+infinity") == FALSE);
15  g_assert(pcmk_str_is_infinity("Infinity") == FALSE);
16  g_assert(pcmk_str_is_infinity("+Infinity") == FALSE);
17 }
18 
19 static void
20 added_whitespace_fails(void) {
21  g_assert(pcmk_str_is_infinity(" INFINITY") == FALSE);
22  g_assert(pcmk_str_is_infinity("INFINITY ") == FALSE);
23  g_assert(pcmk_str_is_infinity(" INFINITY ") == FALSE);
24  g_assert(pcmk_str_is_infinity("+ INFINITY") == FALSE);
25 }
26 
27 static void
28 empty_str_fails(void) {
29  g_assert(pcmk_str_is_infinity(NULL) == FALSE);
30  g_assert(pcmk_str_is_infinity("") == FALSE);
31 }
32 
33 static void
34 minus_infinity_fails(void) {
35  g_assert(pcmk_str_is_infinity("-INFINITY") == FALSE);
36 }
37 
38 int main(int argc, char **argv) {
39  g_test_init(&argc, &argv, NULL);
40 
41  g_test_add_func("/common/utils/infinity/uppercase", uppercase_str_passes);
42  g_test_add_func("/common/utils/infinity/mixed_case", mixed_case_str_fails);
43  g_test_add_func("/common/utils/infinity/whitespace", added_whitespace_fails);
44  g_test_add_func("/common/utils/infinity/empty", empty_str_fails);
45  g_test_add_func("/common/utils/infinity/minus_infinity", minus_infinity_fails);
46 
47  return g_test_run();
48 }
bool pcmk_str_is_infinity(const char *s)
Definition: utils.c:620
int main(int argc, char **argv)