Skip to content

Commit 43e190e

Browse files
authored
Merge pull request #394 from rjmill/rjmill/bools-and-1s-and-0s-inside-objects-and-arrays
more tests for true != 1 and false != 0 inside objects/arrays
2 parents 85f0d45 + 2106ed1 commit 43e190e

File tree

8 files changed

+302
-0
lines changed

8 files changed

+302
-0
lines changed

tests/draft2019-09/const.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,90 @@
125125
}
126126
]
127127
},
128+
{
129+
"description": "const with [false] does not match [0]",
130+
"schema": {"const": [false]},
131+
"tests": [
132+
{
133+
"description": "[false] is valid",
134+
"data": [false],
135+
"valid": true
136+
},
137+
{
138+
"description": "[0] is invalid",
139+
"data": [0],
140+
"valid": false
141+
},
142+
{
143+
"description": "[0.0] is invalid",
144+
"data": [0.0],
145+
"valid": false
146+
}
147+
]
148+
},
149+
{
150+
"description": "const with [true] does not match [1]",
151+
"schema": {"const": [true]},
152+
"tests": [
153+
{
154+
"description": "[true] is valid",
155+
"data": [true],
156+
"valid": true
157+
},
158+
{
159+
"description": "[1] is invalid",
160+
"data": [1],
161+
"valid": false
162+
},
163+
{
164+
"description": "[1.0] is invalid",
165+
"data": [1.0],
166+
"valid": false
167+
}
168+
]
169+
},
170+
{
171+
"description": "const with {\"a\": false} does not match {\"a\": 0}]",
172+
"schema": {"const": {"a": false}},
173+
"tests": [
174+
{
175+
"description": "{\"a\": false} is valid",
176+
"data": {"a": false},
177+
"valid": true
178+
},
179+
{
180+
"description": "{\"a\": 0} is invalid",
181+
"data": {"a": 0},
182+
"valid": false
183+
},
184+
{
185+
"description": "{\"a\": 0.0} is invalid",
186+
"data": {"a": 0.0},
187+
"valid": false
188+
}
189+
]
190+
},
191+
{
192+
"description": "const with {\"a\": true} does not match {\"a\": 1}]",
193+
"schema": {"const": {"a": true}},
194+
"tests": [
195+
{
196+
"description": "{\"a\": true} is valid",
197+
"data": {"a": true},
198+
"valid": true
199+
},
200+
{
201+
"description": "{\"a\": 1} is invalid",
202+
"data": {"a": 1},
203+
"valid": false
204+
},
205+
{
206+
"description": "{\"a\": 1.0} is invalid",
207+
"data": {"a": 1.0},
208+
"valid": false
209+
}
210+
]
211+
},
128212
{
129213
"description": "const with 0 does not match other zero-like types",
130214
"schema": {"const": 0},

tests/draft2019-09/uniqueItems.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@
113113
"description": "objects are non-unique despite key order",
114114
"data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}],
115115
"valid": false
116+
},
117+
{
118+
"description": "{\"a\": false} and {\"a\": 0} are unique",
119+
"data": [{"a": false}, {"a": 0}],
120+
"valid": true
121+
},
122+
{
123+
"description": "{\"a\": true} and {\"a\": 1} are unique",
124+
"data": [{"a": true}, {"a": 1}],
125+
"valid": true
116126
}
117127
]
118128
},

tests/draft3/uniqueItems.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@
9393
"description": "non-unique heterogeneous types are invalid",
9494
"data": [{}, [1], true, null, {}, 1],
9595
"valid": false
96+
},
97+
{
98+
"description": "{\"a\": false} and {\"a\": 0} are unique",
99+
"data": [{"a": false}, {"a": 0}],
100+
"valid": true
101+
},
102+
{
103+
"description": "{\"a\": true} and {\"a\": 1} are unique",
104+
"data": [{"a": true}, {"a": 1}],
105+
"valid": true
96106
}
97107
]
98108
},

tests/draft4/uniqueItems.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@
113113
"description": "objects are non-unique despite key order",
114114
"data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}],
115115
"valid": false
116+
},
117+
{
118+
"description": "{\"a\": false} and {\"a\": 0} are unique",
119+
"data": [{"a": false}, {"a": 0}],
120+
"valid": true
121+
},
122+
{
123+
"description": "{\"a\": true} and {\"a\": 1} are unique",
124+
"data": [{"a": true}, {"a": 1}],
125+
"valid": true
116126
}
117127
]
118128
},

tests/draft6/const.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,90 @@
125125
}
126126
]
127127
},
128+
{
129+
"description": "const with [false] does not match [0]",
130+
"schema": {"const": [false]},
131+
"tests": [
132+
{
133+
"description": "[false] is valid",
134+
"data": [false],
135+
"valid": true
136+
},
137+
{
138+
"description": "[0] is invalid",
139+
"data": [0],
140+
"valid": false
141+
},
142+
{
143+
"description": "[0.0] is invalid",
144+
"data": [0.0],
145+
"valid": false
146+
}
147+
]
148+
},
149+
{
150+
"description": "const with [true] does not match [1]",
151+
"schema": {"const": [true]},
152+
"tests": [
153+
{
154+
"description": "[true] is valid",
155+
"data": [true],
156+
"valid": true
157+
},
158+
{
159+
"description": "[1] is invalid",
160+
"data": [1],
161+
"valid": false
162+
},
163+
{
164+
"description": "[1.0] is invalid",
165+
"data": [1.0],
166+
"valid": false
167+
}
168+
]
169+
},
170+
{
171+
"description": "const with {\"a\": false} does not match {\"a\": 0}]",
172+
"schema": {"const": {"a": false}},
173+
"tests": [
174+
{
175+
"description": "{\"a\": false} is valid",
176+
"data": {"a": false},
177+
"valid": true
178+
},
179+
{
180+
"description": "{\"a\": 0} is invalid",
181+
"data": {"a": 0},
182+
"valid": false
183+
},
184+
{
185+
"description": "{\"a\": 0.0} is invalid",
186+
"data": {"a": 0.0},
187+
"valid": false
188+
}
189+
]
190+
},
191+
{
192+
"description": "const with {\"a\": true} does not match {\"a\": 1}]",
193+
"schema": {"const": {"a": true}},
194+
"tests": [
195+
{
196+
"description": "{\"a\": true} is valid",
197+
"data": {"a": true},
198+
"valid": true
199+
},
200+
{
201+
"description": "{\"a\": 1} is invalid",
202+
"data": {"a": 1},
203+
"valid": false
204+
},
205+
{
206+
"description": "{\"a\": 1.0} is invalid",
207+
"data": {"a": 1.0},
208+
"valid": false
209+
}
210+
]
211+
},
128212
{
129213
"description": "const with 0 does not match other zero-like types",
130214
"schema": {"const": 0},

tests/draft6/uniqueItems.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@
113113
"description": "objects are non-unique despite key order",
114114
"data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}],
115115
"valid": false
116+
},
117+
{
118+
"description": "{\"a\": false} and {\"a\": 0} are unique",
119+
"data": [{"a": false}, {"a": 0}],
120+
"valid": true
121+
},
122+
{
123+
"description": "{\"a\": true} and {\"a\": 1} are unique",
124+
"data": [{"a": true}, {"a": 1}],
125+
"valid": true
116126
}
117127
]
118128
},

tests/draft7/const.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,90 @@
125125
}
126126
]
127127
},
128+
{
129+
"description": "const with [false] does not match [0]",
130+
"schema": {"const": [false]},
131+
"tests": [
132+
{
133+
"description": "[false] is valid",
134+
"data": [false],
135+
"valid": true
136+
},
137+
{
138+
"description": "[0] is invalid",
139+
"data": [0],
140+
"valid": false
141+
},
142+
{
143+
"description": "[0.0] is invalid",
144+
"data": [0.0],
145+
"valid": false
146+
}
147+
]
148+
},
149+
{
150+
"description": "const with [true] does not match [1]",
151+
"schema": {"const": [true]},
152+
"tests": [
153+
{
154+
"description": "[true] is valid",
155+
"data": [true],
156+
"valid": true
157+
},
158+
{
159+
"description": "[1] is invalid",
160+
"data": [1],
161+
"valid": false
162+
},
163+
{
164+
"description": "[1.0] is invalid",
165+
"data": [1.0],
166+
"valid": false
167+
}
168+
]
169+
},
170+
{
171+
"description": "const with {\"a\": false} does not match {\"a\": 0}]",
172+
"schema": {"const": {"a": false}},
173+
"tests": [
174+
{
175+
"description": "{\"a\": false} is valid",
176+
"data": {"a": false},
177+
"valid": true
178+
},
179+
{
180+
"description": "{\"a\": 0} is invalid",
181+
"data": {"a": 0},
182+
"valid": false
183+
},
184+
{
185+
"description": "{\"a\": 0.0} is invalid",
186+
"data": {"a": 0.0},
187+
"valid": false
188+
}
189+
]
190+
},
191+
{
192+
"description": "const with {\"a\": true} does not match {\"a\": 1}]",
193+
"schema": {"const": {"a": true}},
194+
"tests": [
195+
{
196+
"description": "{\"a\": true} is valid",
197+
"data": {"a": true},
198+
"valid": true
199+
},
200+
{
201+
"description": "{\"a\": 1} is invalid",
202+
"data": {"a": 1},
203+
"valid": false
204+
},
205+
{
206+
"description": "{\"a\": 1.0} is invalid",
207+
"data": {"a": 1.0},
208+
"valid": false
209+
}
210+
]
211+
},
128212
{
129213
"description": "const with 0 does not match other zero-like types",
130214
"schema": {"const": 0},

tests/draft7/uniqueItems.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@
113113
"description": "objects are non-unique despite key order",
114114
"data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}],
115115
"valid": false
116+
},
117+
{
118+
"description": "{\"a\": false} and {\"a\": 0} are unique",
119+
"data": [{"a": false}, {"a": 0}],
120+
"valid": true
121+
},
122+
{
123+
"description": "{\"a\": true} and {\"a\": 1} are unique",
124+
"data": [{"a": true}, {"a": 1}],
125+
"valid": true
116126
}
117127
]
118128
},

0 commit comments

Comments
 (0)