This source file includes following definitions.
- empty_input_string
- bad_input_string
- out_of_range
- typical_case
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 empty_input_string(void **state)
16 {
17 int result;
18
19 assert_int_equal(pcmk__scan_port("", &result), EINVAL);
20 assert_int_equal(result, -1);
21 }
22
23 static void
24 bad_input_string(void **state)
25 {
26 int result;
27
28 assert_int_equal(pcmk__scan_port("abc", &result), EINVAL);
29 assert_int_equal(result, -1);
30 }
31
32 static void
33 out_of_range(void **state)
34 {
35 int result;
36
37 assert_int_equal(pcmk__scan_port("-1", &result), pcmk_rc_before_range);
38 assert_int_equal(result, -1);
39 assert_int_equal(pcmk__scan_port("65536", &result), pcmk_rc_after_range);
40 assert_int_equal(result, -1);
41 }
42
43 static void
44 typical_case(void **state)
45 {
46 int result;
47
48 assert_int_equal(pcmk__scan_port("0", &result), pcmk_rc_ok);
49 assert_int_equal(result, 0);
50
51 assert_int_equal(pcmk__scan_port("80", &result), pcmk_rc_ok);
52 assert_int_equal(result, 80);
53 }
54
55 PCMK__UNIT_TEST(NULL, NULL,
56 cmocka_unit_test(empty_input_string),
57 cmocka_unit_test(bad_input_string),
58 cmocka_unit_test(out_of_range),
59 cmocka_unit_test(typical_case))