Skip to content

Commit 3999497

Browse files
committed
Backport the additional min/max tests.
1 parent 12b4a4c commit 3999497

File tree

8 files changed

+179
-4
lines changed

8 files changed

+179
-4
lines changed

tests/draft3/maximum.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,63 @@
88
"data": 2.6,
99
"valid": true
1010
},
11+
{
12+
"description": "boundary point is valid",
13+
"data": 3.0,
14+
"valid": true
15+
},
16+
{
17+
"description": "above the maximum is invalid",
18+
"data": 3.5,
19+
"valid": false
20+
},
21+
{
22+
"description": "ignores non-numbers",
23+
"data": "x",
24+
"valid": true
25+
}
26+
]
27+
},
28+
{
29+
"description": "maximum validation with unsigned integer",
30+
"schema": {"maximum": 300},
31+
"tests": [
32+
{
33+
"description": "below the maximum is invalid",
34+
"data": 299.97,
35+
"valid": true
36+
},
37+
{
38+
"description": "boundary point integer is valid",
39+
"data": 300,
40+
"valid": true
41+
},
42+
{
43+
"description": "boundary point float is valid",
44+
"data": 300.00,
45+
"valid": true
46+
},
47+
{
48+
"description": "above the maximum is invalid",
49+
"data": 300.5,
50+
"valid": false
51+
}
52+
]
53+
},
54+
{
55+
"description": "maximum validation (explicit false exclusivity)",
56+
"schema": {"maximum": 3.0, "exclusiveMaximum": false},
57+
"tests": [
58+
{
59+
"description": "below the maximum is valid",
60+
"data": 2.6,
61+
"valid": true
62+
},
63+
{
64+
"description": "boundary point is valid",
65+
"data": 3.0,
66+
"valid": true
67+
},
1168
{
1269
"description": "above the maximum is invalid",
1370
"data": 3.5,

tests/draft3/minimum.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,17 @@
5959
"valid": true
6060
},
6161
{
62-
"description": "below the minimum is invalid",
62+
"description": "boundary point with float is valid",
63+
"data": -2.0,
64+
"valid": true
65+
},
66+
{
67+
"description": "float below the minimum is invalid",
68+
"data": -2.0001,
69+
"valid": false
70+
},
71+
{
72+
"description": "int below the minimum is invalid",
6373
"data": -3,
6474
"valid": false
6575
},

tests/draft4/maximum.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,32 @@
2525
}
2626
]
2727
},
28+
{
29+
"description": "maximum validation with unsigned integer",
30+
"schema": {"maximum": 300},
31+
"tests": [
32+
{
33+
"description": "below the maximum is invalid",
34+
"data": 299.97,
35+
"valid": true
36+
},
37+
{
38+
"description": "boundary point integer is valid",
39+
"data": 300,
40+
"valid": true
41+
},
42+
{
43+
"description": "boundary point float is valid",
44+
"data": 300.00,
45+
"valid": true
46+
},
47+
{
48+
"description": "above the maximum is invalid",
49+
"data": 300.5,
50+
"valid": false
51+
}
52+
]
53+
},
2854
{
2955
"description": "maximum validation (explicit false exclusivity)",
3056
"schema": {"maximum": 3.0, "exclusiveMaximum": false},

tests/draft4/minimum.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,17 @@
9090
"valid": true
9191
},
9292
{
93-
"description": "below the minimum is invalid",
93+
"description": "boundary point with float is valid",
94+
"data": -2.0,
95+
"valid": true
96+
},
97+
{
98+
"description": "float below the minimum is invalid",
99+
"data": -2.0001,
100+
"valid": false
101+
},
102+
{
103+
"description": "int below the minimum is invalid",
94104
"data": -3,
95105
"valid": false
96106
},

tests/draft6/maximum.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,31 @@
2424
"valid": true
2525
}
2626
]
27+
},
28+
{
29+
"description": "maximum validation with unsigned integer",
30+
"schema": {"maximum": 300},
31+
"tests": [
32+
{
33+
"description": "below the maximum is invalid",
34+
"data": 299.97,
35+
"valid": true
36+
},
37+
{
38+
"description": "boundary point integer is valid",
39+
"data": 300,
40+
"valid": true
41+
},
42+
{
43+
"description": "boundary point float is valid",
44+
"data": 300.00,
45+
"valid": true
46+
},
47+
{
48+
"description": "above the maximum is invalid",
49+
"data": 300.5,
50+
"valid": false
51+
}
52+
]
2753
}
2854
]

tests/draft6/minimum.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,17 @@
4545
"valid": true
4646
},
4747
{
48-
"description": "below the minimum is invalid",
48+
"description": "boundary point with float is valid",
49+
"data": -2.0,
50+
"valid": true
51+
},
52+
{
53+
"description": "float below the minimum is invalid",
54+
"data": -2.0001,
55+
"valid": false
56+
},
57+
{
58+
"description": "int below the minimum is invalid",
4959
"data": -3,
5060
"valid": false
5161
},

tests/draft7/maximum.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,31 @@
2424
"valid": true
2525
}
2626
]
27+
},
28+
{
29+
"description": "maximum validation with unsigned integer",
30+
"schema": {"maximum": 300},
31+
"tests": [
32+
{
33+
"description": "below the maximum is invalid",
34+
"data": 299.97,
35+
"valid": true
36+
},
37+
{
38+
"description": "boundary point integer is valid",
39+
"data": 300,
40+
"valid": true
41+
},
42+
{
43+
"description": "boundary point float is valid",
44+
"data": 300.00,
45+
"valid": true
46+
},
47+
{
48+
"description": "above the maximum is invalid",
49+
"data": 300.5,
50+
"valid": false
51+
}
52+
]
2753
}
2854
]

tests/draft7/minimum.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,17 @@
4545
"valid": true
4646
},
4747
{
48-
"description": "below the minimum is invalid",
48+
"description": "boundary point with float is valid",
49+
"data": -2.0,
50+
"valid": true
51+
},
52+
{
53+
"description": "float below the minimum is invalid",
54+
"data": -2.0001,
55+
"valid": false
56+
},
57+
{
58+
"description": "int below the minimum is invalid",
4959
"data": -3,
5060
"valid": false
5161
},

0 commit comments

Comments
 (0)