This source file includes following definitions.
- empty_input_string
- bad_input_string
- trailing_chars
- no_result_variable
- 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 long long result;
18
19 assert_int_equal(pcmk__scan_ll(NULL, &result, 47), pcmk_rc_ok);
20 assert_int_equal(result, 47);
21 }
22
23 static void
24 bad_input_string(void **state)
25 {
26 long long result;
27
28 assert_int_equal(pcmk__scan_ll("asdf", &result, 47), EINVAL);
29 assert_int_equal(result, 47);
30 assert_int_equal(pcmk__scan_ll("as12", &result, 47), EINVAL);
31 assert_int_equal(result, 47);
32 }
33
34 static void
35 trailing_chars(void **state)
36 {
37 long long result;
38
39 assert_int_equal(pcmk__scan_ll("12as", &result, 47), pcmk_rc_ok);
40 assert_int_equal(result, 12);
41 }
42
43 static void
44 no_result_variable(void **state)
45 {
46 assert_int_equal(pcmk__scan_ll("1234", NULL, 47), pcmk_rc_ok);
47 assert_int_equal(pcmk__scan_ll("asdf", NULL, 47), EINVAL);
48 }
49
50 static void
51 typical_case(void **state)
52 {
53 long long result;
54
55 assert_int_equal(pcmk__scan_ll("1234", &result, 47), pcmk_rc_ok);
56 assert_int_equal(result, 1234);
57 }
58
59 PCMK__UNIT_TEST(NULL, NULL,
60 cmocka_unit_test(empty_input_string),
61 cmocka_unit_test(bad_input_string),
62 cmocka_unit_test(trailing_chars),
63 cmocka_unit_test(no_result_variable),
64 cmocka_unit_test(typical_case))