Debian Codegraph @

share/tests/v1/format/duration.json

raw
1 [
2 {
3 "description": "validation of duration strings",
4 "comment": "RFC 3339 Appendix A defines the ABNF grammar for ISO-8601 durations used by JSON Schema format 'duration'. These tests enforce only the syntax defined by that grammar.",
5 "schema": {
6 "$schema": "https://json-schema.org/v1",
7 "format": "duration"
8 },
9 "tests": [
10 {
11 "description": "all string formats ignore integers",
12 "data": 12,
13 "valid": true
14 },
15 {
16 "description": "all string formats ignore floats",
17 "data": 13.7,
18 "valid": true
19 },
20 {
21 "description": "all string formats ignore objects",
22 "data": {},
23 "valid": true
24 },
25 {
26 "description": "all string formats ignore arrays",
27 "data": [],
28 "valid": true
29 },
30 {
31 "description": "all string formats ignore booleans",
32 "data": false,
33 "valid": true
34 },
35 {
36 "description": "all string formats ignore nulls",
37 "data": null,
38 "valid": true
39 },
40 {
41 "description": "a valid duration string",
42 "data": "P4DT12H30M5S",
43 "valid": true
44 },
45 {
46 "description": "an invalid duration string",
47 "data": "PT1D",
48 "valid": false
49 },
50 {
51 "description": "must start with P",
52 "data": "4DT12H30M5S",
53 "valid": false
54 },
55 {
56 "description": "no elements present",
57 "data": "P",
58 "valid": false
59 },
60 {
61 "description": "no time elements present",
62 "data": "P1YT",
63 "valid": false
64 },
65 {
66 "description": "no date or time elements present",
67 "data": "PT",
68 "valid": false
69 },
70 {
71 "description": "elements out of order",
72 "data": "P2D1Y",
73 "valid": false
74 },
75 {
76 "description": "missing time separator",
77 "data": "P1D2H",
78 "valid": false
79 },
80 {
81 "description": "time element in the date position",
82 "data": "P2S",
83 "valid": false
84 },
85 {
86 "description": "four years duration",
87 "data": "P4Y",
88 "valid": true
89 },
90 {
91 "description": "zero time, in seconds",
92 "data": "PT0S",
93 "valid": true
94 },
95 {
96 "description": "zero time, in days",
97 "data": "P0D",
98 "valid": true
99 },
100 {
101 "description": "one month duration",
102 "data": "P1M",
103 "valid": true
104 },
105 {
106 "description": "one minute duration",
107 "data": "PT1M",
108 "valid": true
109 },
110 {
111 "description": "one and a half days, in hours",
112 "data": "PT36H",
113 "valid": true
114 },
115 {
116 "description": "one and a half days, in days and hours",
117 "data": "P1DT12H",
118 "valid": true
119 },
120 {
121 "description": "two weeks",
122 "data": "P2W",
123 "valid": true
124 },
125 {
126 "description": "weeks cannot be combined with other units",
127 "data": "P1Y2W",
128 "valid": false
129 },
130 {
131 "description": "invalid non-ASCII '২' (a Bengali 2)",
132 "data": "P২Y",
133 "valid": false
134 },
135 {
136 "description": "element without unit",
137 "data": "P1",
138 "valid": false
139 },
140 {
141 "description": "all date and time components",
142 "data": "P1Y2M3DT4H5M6S",
143 "valid": true
144 },
145 {
146 "description": "date components only",
147 "data": "P1Y2M3D",
148 "valid": true
149 },
150 {
151 "description": "time components only",
152 "data": "PT1H2M3S",
153 "valid": true
154 },
155 {
156 "description": "month and day",
157 "data": "P1M2D",
158 "valid": true
159 },
160 {
161 "description": "hour and minute",
162 "data": "PT1H30M",
163 "valid": true
164 },
165 {
166 "description": "multi-digit values in all components",
167 "data": "P10Y10M10DT10H10M10S",
168 "valid": true
169 },
170 {
171 "description": "fractional duration is not allowed by RFC 3339 ABNF",
172 "comment": "numeric components use 1*DIGIT where DIGIT = %x30-39; '.' is not allowed",
173 "data": "PT0.5S",
174 "valid": false
175 },
176 {
177 "description": "leading whitespace is invalid",
178 "data": " P1D",
179 "valid": false
180 },
181 {
182 "description": "trailing whitespace is invalid",
183 "data": "P1D ",
184 "valid": false
185 },
186 {
187 "description": "empty string is invalid",
188 "data": "",
189 "valid": false
190 },
191 {
192 "description": "years and months can appear without days",
193 "data": "P1Y2M",
194 "valid": true
195 },
196 {
197 "description": "years and days cannot appear without months",
198 "data": "P1Y2D",
199 "valid": false
200 },
201 {
202 "description": "months and days can appear without years",
203 "data": "P1M2D",
204 "valid": true
205 },
206 {
207 "description": "hours and minutes can appear without seconds",
208 "data": "PT1H2M",
209 "valid": true
210 },
211 {
212 "description": "hours and seconds cannot appear without minutes",
213 "data": "PT1H2S",
214 "valid": false
215 },
216 {
217 "description": "minutes and seconds can appear without hour",
218 "data": "PT1M2S",
219 "valid": true
220 },
221 {
222 "description": "a leading sign is not allowed",
223 "data": "-P1D",
224 "valid": false
225 },
226 {
227 "description": "a number before the time separator has no unit",
228 "data": "P1D2T3H",
229 "valid": false
230 },
231 {
232 "description": "exponent notation is not allowed in a component",
233 "data": "P1e2D",
234 "valid": false
235 },
236 {
237 "description": "a trailing newline is invalid",
238 "data": "P1D\n",
239 "valid": false
240 },
241 {
242 "description": "weeks cannot be combined with a time component",
243 "data": "P1WT1H",
244 "valid": false
245 },
246 {
247 "description": "weeks cannot be combined with a zero-valued component",
248 "data": "P0Y1W",
249 "valid": false
250 },
251 {
252 "description": "a leading zero in a component is valid",
253 "data": "P01D",
254 "valid": true
255 },
256 {
257 "description": "a component with many digits is valid",
258 "data": "P999999999999999999999999999999999999999999999999999999999999999999999999999999D",
259 "valid": true
260 },
261 {
262 "description": "a comma as the decimal separator is invalid",
263 "data": "PT0,5S",
264 "valid": false
265 },
266 {
267 "description": "a sign inside a component is invalid",
268 "data": "P-1D",
269 "valid": false
270 }
271 ]
272 }
273 ]