Skip to content

Commit 6cf6ff8

Browse files
committed
Squashed 'json/' changes from eb619047f..ab0b1ae71
ab0b1ae71 fix draft4 schemas 0df96bc38 group tests to avoid duplicating test descriptions 93293efca fix indentation 76b529ff6 Merge pull request #482 from json-schema-org/ether/more-date-time-tests 57f1d63d7 some more tests for "date" and "time" formats git-subtree-dir: json git-subtree-split: ab0b1ae710158817af2e48556e22377363aeb169
1 parent 2591383 commit 6cf6ff8

File tree

17 files changed

+679
-431
lines changed

17 files changed

+679
-431
lines changed

tests/draft-future/optional/bignum.json

+11-23
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
11
[
22
{
33
"description": "integer",
4-
"schema": {"type": "integer"},
4+
"schema": { "type": "integer" },
55
"tests": [
66
{
77
"description": "a bignum is an integer",
88
"data": 12345678910111213141516171819202122232425262728293031,
99
"valid": true
10-
}
11-
]
12-
},
13-
{
14-
"description": "number",
15-
"schema": {"type": "number"},
16-
"tests": [
17-
{
18-
"description": "a bignum is a number",
19-
"data": 98249283749234923498293171823948729348710298301928331,
20-
"valid": true
21-
}
22-
]
23-
},
24-
{
25-
"description": "integer",
26-
"schema": {"type": "integer"},
27-
"tests": [
10+
},
2811
{
2912
"description": "a negative bignum is an integer",
3013
"data": -12345678910111213141516171819202122232425262728293031,
@@ -34,8 +17,13 @@
3417
},
3518
{
3619
"description": "number",
37-
"schema": {"type": "number"},
20+
"schema": { "type": "number" },
3821
"tests": [
22+
{
23+
"description": "a bignum is a number",
24+
"data": 98249283749234923498293171823948729348710298301928331,
25+
"valid": true
26+
},
3927
{
4028
"description": "a negative bignum is a number",
4129
"data": -98249283749234923498293171823948729348710298301928331,
@@ -45,7 +33,7 @@
4533
},
4634
{
4735
"description": "string",
48-
"schema": {"type": "string"},
36+
"schema": { "type": "string" },
4937
"tests": [
5038
{
5139
"description": "a bignum is not a string",
@@ -56,7 +44,7 @@
5644
},
5745
{
5846
"description": "integer comparison",
59-
"schema": {"maximum": 18446744073709551615},
47+
"schema": { "maximum": 18446744073709551615 },
6048
"tests": [
6149
{
6250
"description": "comparison works for high numbers",
@@ -80,7 +68,7 @@
8068
},
8169
{
8270
"description": "integer comparison",
83-
"schema": {"minimum": -18446744073709551615},
71+
"schema": { "minimum": -18446744073709551615 },
8472
"tests": [
8573
{
8674
"description": "comparison works for very negative numbers",

tests/draft-future/optional/format/date.json

+22-2
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,34 @@
154154
"valid": false
155155
},
156156
{
157-
"description": "invalidates non-padded month dates",
157+
"description": "non-padded month dates are not valid",
158158
"data": "1998-1-20",
159159
"valid": false
160160
},
161161
{
162-
"description": "invalidates non-padded day dates",
162+
"description": "non-padded day dates are not valid",
163163
"data": "1998-01-1",
164164
"valid": false
165+
},
166+
{
167+
"description": "invalid month",
168+
"data": "1998-13-01",
169+
"valid": false
170+
},
171+
{
172+
"description": "invalid month-day combination",
173+
"data": "1998-04-31",
174+
"valid": false
175+
},
176+
{
177+
"description": "2021 is not a leap year",
178+
"data": "2021-02-29",
179+
"valid": false
180+
},
181+
{
182+
"description": "2020 is a leap year",
183+
"data": "2020-02-29",
184+
"valid": true
165185
}
166186
]
167187
}
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,93 @@
11
[
2-
{
3-
"description": "validation of duration strings",
4-
"schema": {"format": "duration"},
5-
"tests": [
6-
{
7-
"description": "a valid duration string",
8-
"data": "P4DT12H30M5S",
9-
"valid": true
10-
},
11-
{
12-
"description": "an invalid duration string",
13-
"data": "PT1D",
14-
"valid": false
15-
},
16-
{
17-
"description": "no elements present",
18-
"data": "P",
19-
"valid": false
20-
},
21-
{
22-
"description": "no time elements present",
23-
"data": "P1YT",
24-
"valid": false
25-
},
26-
{
27-
"description": "no date or time elements present",
28-
"data": "PT",
29-
"valid": false
30-
},
31-
{
32-
"description": "elements out of order",
33-
"data": "P2D1Y",
34-
"valid": false
35-
},
36-
{
37-
"description": "missing time separator",
38-
"data": "P1D2H",
39-
"valid": false
40-
},
41-
{
42-
"description": "time element in the date position",
43-
"data": "P2S",
44-
"valid": false
45-
},
46-
{
47-
"description": "four years duration",
48-
"data": "P4Y",
49-
"valid": true
50-
},
51-
{
52-
"description": "zero time, in seconds",
53-
"data": "PT0S",
54-
"valid": true
55-
},
56-
{
57-
"description": "zero time, in days",
58-
"data": "P0D",
59-
"valid": true
60-
},
61-
{
62-
"description": "one month duration",
63-
"data": "P1M",
64-
"valid": true
65-
},
66-
{
67-
"description": "one minute duration",
68-
"data": "PT1M",
69-
"valid": true
70-
},
71-
{
72-
"description": "one and a half days, in hours",
73-
"data": "PT36H",
74-
"valid": true
75-
},
76-
{
77-
"description": "one and a half days, in days and hours",
78-
"data": "P1DT12H",
79-
"valid": true
80-
},
81-
{
82-
"description": "two weeks",
83-
"data": "P2W",
84-
"valid": true
85-
},
86-
{
87-
"description": "weeks cannot be combined with other units",
88-
"data": "P1Y2W",
89-
"valid": false
90-
}
91-
]
92-
}
2+
{
3+
"description": "validation of duration strings",
4+
"schema": {"format": "duration"},
5+
"tests": [
6+
{
7+
"description": "a valid duration string",
8+
"data": "P4DT12H30M5S",
9+
"valid": true
10+
},
11+
{
12+
"description": "an invalid duration string",
13+
"data": "PT1D",
14+
"valid": false
15+
},
16+
{
17+
"description": "no elements present",
18+
"data": "P",
19+
"valid": false
20+
},
21+
{
22+
"description": "no time elements present",
23+
"data": "P1YT",
24+
"valid": false
25+
},
26+
{
27+
"description": "no date or time elements present",
28+
"data": "PT",
29+
"valid": false
30+
},
31+
{
32+
"description": "elements out of order",
33+
"data": "P2D1Y",
34+
"valid": false
35+
},
36+
{
37+
"description": "missing time separator",
38+
"data": "P1D2H",
39+
"valid": false
40+
},
41+
{
42+
"description": "time element in the date position",
43+
"data": "P2S",
44+
"valid": false
45+
},
46+
{
47+
"description": "four years duration",
48+
"data": "P4Y",
49+
"valid": true
50+
},
51+
{
52+
"description": "zero time, in seconds",
53+
"data": "PT0S",
54+
"valid": true
55+
},
56+
{
57+
"description": "zero time, in days",
58+
"data": "P0D",
59+
"valid": true
60+
},
61+
{
62+
"description": "one month duration",
63+
"data": "P1M",
64+
"valid": true
65+
},
66+
{
67+
"description": "one minute duration",
68+
"data": "PT1M",
69+
"valid": true
70+
},
71+
{
72+
"description": "one and a half days, in hours",
73+
"data": "PT36H",
74+
"valid": true
75+
},
76+
{
77+
"description": "one and a half days, in days and hours",
78+
"data": "P1DT12H",
79+
"valid": true
80+
},
81+
{
82+
"description": "two weeks",
83+
"data": "P2W",
84+
"valid": true
85+
},
86+
{
87+
"description": "weeks cannot be combined with other units",
88+
"data": "P1Y2W",
89+
"valid": false
90+
}
91+
]
92+
}
9393
]

tests/draft-future/optional/format/time.json

+63-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,75 @@
99
"valid": true
1010
},
1111
{
12-
"description": "a valid time string with leap second",
12+
"description": "a valid time string with leap second, Zulu",
1313
"data": "23:59:60Z",
1414
"valid": true
1515
},
1616
{
17-
"description": "a valid time string with leap second with offset",
17+
"description": "invalid leap second, Zulu (wrong hour)",
18+
"data": "22:59:60Z",
19+
"valid": false
20+
},
21+
{
22+
"description": "invalid leap second, Zulu (wrong minute)",
23+
"data": "23:58:60Z",
24+
"valid": false
25+
},
26+
{
27+
"description": "valid leap second, zero time-offset",
28+
"data": "23:59:60+00:00",
29+
"valid": true
30+
},
31+
{
32+
"description": "invalid leap second, zero time-offset (wrong hour)",
33+
"data": "22:59:60+00:00",
34+
"valid": false
35+
},
36+
{
37+
"description": "invalid leap second, zero time-offset (wrong minute)",
38+
"data": "23:58:60+00:00",
39+
"valid": false
40+
},
41+
{
42+
"description": "valid leap second, positive time-offset",
43+
"data": "01:29:60+01:30",
44+
"valid": true
45+
},
46+
{
47+
"description": "valid leap second, large positive time-offset",
48+
"data": "23:29:60+23:30",
49+
"valid": true
50+
},
51+
{
52+
"description": "invalid leap second, positive time-offset (wrong hour)",
53+
"data": "23:59:60+01:00",
54+
"valid": false
55+
},
56+
{
57+
"description": "invalid leap second, positive time-offset (wrong minute)",
58+
"data": "23:59:60+00:30",
59+
"valid": false
60+
},
61+
{
62+
"description": "valid leap second, negative time-offset",
1863
"data": "15:59:60-08:00",
1964
"valid": true
2065
},
66+
{
67+
"description": "valid leap second, large negative time-offset",
68+
"data": "00:29:60-23:30",
69+
"valid": true
70+
},
71+
{
72+
"description": "invalid leap second, negative time-offset (wrong hour)",
73+
"data": "23:59:60-01:00",
74+
"valid": false
75+
},
76+
{
77+
"description": "invalid leap second, negative time-offset (wrong minute)",
78+
"data": "23:59:60-00:30",
79+
"valid": false
80+
},
2181
{
2282
"description": "a valid time string with second fraction",
2383
"data": "23:20:50.52Z",
@@ -84,7 +144,7 @@
84144
"valid": false
85145
},
86146
{
87-
"description": "an invalid time string",
147+
"description": "an invalid offset indicator",
88148
"data": "08:30:06 PST",
89149
"valid": false
90150
},

0 commit comments

Comments
 (0)