pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
pcmk_str_is_minus_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_minus_infinity("-INFINITY"));
18 }
19 
20 static void
21 mixed_case_str_fails(void **state)
22 {
23  assert_false(pcmk_str_is_minus_infinity("-infinity"));
24  assert_false(pcmk_str_is_minus_infinity("-Infinity"));
25 }
26 
27 static void
28 added_whitespace_fails(void **state)
29 {
30  assert_false(pcmk_str_is_minus_infinity(" -INFINITY"));
31  assert_false(pcmk_str_is_minus_infinity("-INFINITY "));
32  assert_false(pcmk_str_is_minus_infinity(" -INFINITY "));
33  assert_false(pcmk_str_is_minus_infinity("- INFINITY"));
34 }
35 
36 static void
37 empty_str_fails(void **state)
38 {
39  assert_false(pcmk_str_is_minus_infinity(NULL));
40  assert_false(pcmk_str_is_minus_infinity(""));
41 }
42 
43 static void
44 infinity_fails(void **state)
45 {
46  assert_false(pcmk_str_is_minus_infinity("INFINITY"));
47 }
48 
49 PCMK__UNIT_TEST(NULL, NULL,
50  cmocka_unit_test(uppercase_str_passes),
51  cmocka_unit_test(mixed_case_str_fails),
52  cmocka_unit_test(added_whitespace_fails),
53  cmocka_unit_test(empty_str_fails),
54  cmocka_unit_test(infinity_fails))
PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(bad_input), cmocka_unit_test(not_found), cmocka_unit_test(find_attrB), cmocka_unit_test(find_attrA_matching))
bool pcmk_str_is_minus_infinity(const char *s)
Definition: utils.c:548