This source file includes following definitions.
- empty_arg
- invalid_arg
- valid_arg
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/unittest_internal.h>
13
14 #include <crm/common/iso8601.h>
15 #include "crmcommon_private.h"
16
17 static void
18 empty_arg(void **state)
19 {
20 assert_null(crm_time_parse_duration(NULL));
21 assert_null(crm_time_parse_duration(""));
22 }
23
24 static void
25 invalid_arg(void **state)
26 {
27
28 assert_null(crm_time_parse_duration("X3Y6M4DT12H30M5S"));
29
30
31 assert_null(crm_time_parse_duration("P"));
32 assert_null(crm_time_parse_duration("P 3Y6M4DT12H30M5S"));
33 assert_null(crm_time_parse_duration("PX3Y6M4DT12H30M5S"));
34
35
36 assert_null(crm_time_parse_duration("P2147483648Y6M4DT12H30M5S"));
37 assert_null(crm_time_parse_duration("P3Y2147483648M4DT12H30M5S"));
38 assert_null(crm_time_parse_duration("P3Y6M2147483648DT12H30M5S"));
39 assert_null(crm_time_parse_duration("P3Y6M4DT2147483648H30M5S"));
40 assert_null(crm_time_parse_duration("P3Y6M4DT12H2147483648M5S"));
41 assert_null(crm_time_parse_duration("P3Y6M4DT12H30MP2147483648S"));
42
43
44 assert_null(crm_time_parse_duration("P3Y6M4DT12H30M5"));
45 assert_null(crm_time_parse_duration("P3Y6M4DT12H30M5X"));
46 assert_null(crm_time_parse_duration("P3X6M4DT12H30M5S"));
47 assert_null(crm_time_parse_duration("PT"));
48 assert_null(crm_time_parse_duration("P/"));
49
50 #if 0
51
52
53
54 assert_null(crm_time_parse_duration("P6M3Y4DT12H30M5S"));
55 assert_null(crm_time_parse_duration("P6M3DT12HY430M5S"));
56
57
58 assert_null(crm_time_parse_duration("P6Y4M3D1MT12H30M5S"));
59
60
61 assert_null(crm_time_parse_duration("P6Y4M3W3D1MT12H30M5S"));
62 assert_null(crm_time_parse_duration("P3WT12H30M5S"));
63 #endif
64 }
65
66 static void
67 valid_arg(void **state)
68 {
69
70 assert_non_null(crm_time_parse_duration("P3Y6M4DT12H30M5S"));
71 assert_non_null(crm_time_parse_duration("P3Y6M4DT12H30M"));
72 assert_non_null(crm_time_parse_duration("P3Y6M4D"));
73 assert_non_null(crm_time_parse_duration("P1M"));
74 assert_non_null(crm_time_parse_duration("PT1M"));
75 assert_non_null(crm_time_parse_duration("P7W"));
76
77 #if 0
78
79
80
81 assert_non_null(crm_time_parse_duration("P3Y6M4DT12H30.5M"));
82 assert_non_null(crm_time_parse_duration("P3Y6M4DT12H30,5M"));
83
84
85 assert_non_null(crm_time_parse_duration("P0003-02-01T11:10:09");
86 #endif
87 }
88
89 PCMK__UNIT_TEST(NULL, NULL,
90 cmocka_unit_test(empty_arg),
91 cmocka_unit_test(invalid_arg),
92 cmocka_unit_test(valid_arg));