Skip to content

Commit f2720d3

Browse files
more tests for the duration format: missing units (#875)
1 parent e391238 commit f2720d3

3 files changed

Lines changed: 90 additions & 0 deletions

File tree

tests/draft2019-09/optional/format/duration.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,36 @@
187187
"description": "empty string is invalid",
188188
"data": "",
189189
"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
190220
}
191221
]
192222
}

tests/draft2020-12/optional/format/duration.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,36 @@
187187
"description": "empty string is invalid",
188188
"data": "",
189189
"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
190220
}
191221
]
192222
}

tests/v1/format/duration.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,36 @@
187187
"description": "empty string is invalid",
188188
"data": "",
189189
"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
190220
}
191221
]
192222
}

0 commit comments

Comments
 (0)