This source file includes following definitions.
- bad_input
- is_true
- is_false
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/unittest_internal.h>
13
14 static void
15 bad_input(void **state) {
16 assert_false(crm_is_true(NULL));
17 }
18
19 static void
20 is_true(void **state) {
21 assert_true(crm_is_true("true"));
22 assert_true(crm_is_true("TrUe"));
23 assert_true(crm_is_true("on"));
24 assert_true(crm_is_true("ON"));
25 assert_true(crm_is_true("yes"));
26 assert_true(crm_is_true("yES"));
27 assert_true(crm_is_true("y"));
28 assert_true(crm_is_true("Y"));
29 assert_true(crm_is_true("1"));
30 }
31
32 static void
33 is_false(void **state) {
34 assert_false(crm_is_true("false"));
35 assert_false(crm_is_true("fAlSe"));
36 assert_false(crm_is_true("off"));
37 assert_false(crm_is_true("OFF"));
38 assert_false(crm_is_true("no"));
39 assert_false(crm_is_true("No"));
40 assert_false(crm_is_true("n"));
41 assert_false(crm_is_true("N"));
42 assert_false(crm_is_true("0"));
43
44 assert_false(crm_is_true(""));
45 assert_false(crm_is_true("blahblah"));
46
47 assert_false(crm_is_true("truedat"));
48 assert_false(crm_is_true("onnn"));
49 assert_false(crm_is_true("yep"));
50 assert_false(crm_is_true("Y!"));
51 assert_false(crm_is_true("100"));
52 }
53
54 PCMK__UNIT_TEST(NULL, NULL,
55 cmocka_unit_test(bad_input),
56 cmocka_unit_test(is_true),
57 cmocka_unit_test(is_false))