pacemaker  2.1.9-49aab99839
Scalable High-Availability cluster resource manager
pcmk_str_is_infinity_test.c
Go to the documentation of this file.
1 /*
2  * Copyright 2020-2021 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 General Public License version 2
7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
8  */
9 
10 #include <crm_internal.h>
11 
13 
14 static void
15 uppercase_str_passes(void **state)
16 {
17  assert_true(pcmk_str_is_infinity("INFINITY"));
18  assert_true(pcmk_str_is_infinity("+INFINITY"));
19 }
20 
21 static void
22 mixed_case_str_fails(void **state)
23 {
24  assert_false(pcmk_str_is_infinity("infinity"));
25  assert_false(pcmk_str_is_infinity("+infinity"));
26  assert_false(pcmk_str_is_infinity("Infinity"));
27  assert_false(pcmk_str_is_infinity("+Infinity"));
28 }
29 
30 static void
31 added_whitespace_fails(void **state)
32 {
33  assert_false(pcmk_str_is_infinity(" INFINITY"));
34  assert_false(pcmk_str_is_infinity("INFINITY "));
35  assert_false(pcmk_str_is_infinity(" INFINITY "));
36  assert_false(pcmk_str_is_infinity("+ INFINITY"));
37 }
38 
39 static void
40 empty_str_fails(void **state)
41 {
42  assert_false(pcmk_str_is_infinity(NULL));
43  assert_false(pcmk_str_is_infinity(""));
44 }
45 
46 static void
47 minus_infinity_fails(void **state)
48 {
49  assert_false(pcmk_str_is_infinity("-INFINITY"));
50 }
51 
52 PCMK__UNIT_TEST(NULL, NULL,
53  cmocka_unit_test(uppercase_str_passes),
54  cmocka_unit_test(mixed_case_str_fails),
55  cmocka_unit_test(added_whitespace_fails),
56  cmocka_unit_test(empty_str_fails),
57  cmocka_unit_test(minus_infinity_fails))
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
bool pcmk_str_is_infinity(const char *s)
Definition: utils.c:340