Debian Codegraph @

share/tests/draft7/uniqueItems.json

raw
1 [
2 {
3 "description": "uniqueItems validation",
4 "schema": {"uniqueItems": true},
5 "tests": [
6 {
7 "description": "unique array of integers is valid",
8 "data": [1, 2],
9 "valid": true
10 },
11 {
12 "description": "non-unique array of integers is invalid",
13 "data": [1, 1],
14 "valid": false
15 },
16 {
17 "description": "non-unique array of more than two integers is invalid",
18 "data": [1, 2, 1],
19 "valid": false
20 },
21 {
22 "description": "numbers are unique if mathematically unequal",
23 "data": [1.0, 1.00, 1],
24 "valid": false
25 },
26 {
27 "description": "false is not equal to zero",
28 "data": [0, false],
29 "valid": true
30 },
31 {
32 "description": "true is not equal to one",
33 "data": [1, true],
34 "valid": true
35 },
36 {
37 "description": "unique array of strings is valid",
38 "data": ["foo", "bar", "baz"],
39 "valid": true
40 },
41 {
42 "description": "non-unique array of strings is invalid",
43 "data": ["foo", "bar", "foo"],
44 "valid": false
45 },
46 {
47 "description": "unique array of objects is valid",
48 "data": [{"foo": "bar"}, {"foo": "baz"}],
49 "valid": true
50 },
51 {
52 "description": "non-unique array of objects is invalid",
53 "data": [{"foo": "bar"}, {"foo": "bar"}],
54 "valid": false
55 },
56 {
57 "description": "property order of array of objects is ignored",
58 "data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
59 "valid": false
60 },
61 {
62 "description": "unique array of nested objects is valid",
63 "data": [
64 {"foo": {"bar" : {"baz" : true}}},
65 {"foo": {"bar" : {"baz" : false}}}
66 ],
67 "valid": true
68 },
69 {
70 "description": "non-unique array of nested objects is invalid",
71 "data": [
72 {"foo": {"bar" : {"baz" : true}}},
73 {"foo": {"bar" : {"baz" : true}}}
74 ],
75 "valid": false
76 },
77 {
78 "description": "unique array of arrays is valid",
79 "data": [["foo"], ["bar"]],
80 "valid": true
81 },
82 {
83 "description": "non-unique array of arrays is invalid",
84 "data": [["foo"], ["foo"]],
85 "valid": false
86 },
87 {
88 "description": "non-unique array of more than two arrays is invalid",
89 "data": [["foo"], ["bar"], ["foo"]],
90 "valid": false
91 },
92 {
93 "description": "1 and true are unique",
94 "data": [1, true],
95 "valid": true
96 },
97 {
98 "description": "0 and false are unique",
99 "data": [0, false],
100 "valid": true
101 },
102 {
103 "description": "[1] and [true] are unique",
104 "data": [[1], [true]],
105 "valid": true
106 },
107 {
108 "description": "[0] and [false] are unique",
109 "data": [[0], [false]],
110 "valid": true
111 },
112 {
113 "description": "nested [1] and [true] are unique",
114 "data": [[[1], "foo"], [[true], "foo"]],
115 "valid": true
116 },
117 {
118 "description": "nested [0] and [false] are unique",
119 "data": [[[0], "foo"], [[false], "foo"]],
120 "valid": true
121 },
122 {
123 "description": "unique heterogeneous types are valid",
124 "data": [{}, [1], true, null, 1, "{}"],
125 "valid": true
126 },
127 {
128 "description": "non-unique heterogeneous types are invalid",
129 "data": [{}, [1], true, null, {}, 1],
130 "valid": false
131 },
132 {
133 "description": "different objects are unique",
134 "data": [{"a": 1, "b": 2}, {"a": 2, "b": 1}],
135 "valid": true
136 },
137 {
138 "description": "objects are non-unique despite key order",
139 "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}],
140 "valid": false
141 },
142 {
143 "description": "{\"a\": false} and {\"a\": 0} are unique",
144 "data": [{"a": false}, {"a": 0}],
145 "valid": true
146 },
147 {
148 "description": "{\"a\": true} and {\"a\": 1} are unique",
149 "data": [{"a": true}, {"a": 1}],
150 "valid": true
151 }
152 ]
153 },
154 {
155 "description": "uniqueItems with an array of items",
156 "schema": {
157 "items": [{"type": "boolean"}, {"type": "boolean"}],
158 "uniqueItems": true
159 },
160 "tests": [
161 {
162 "description": "[false, true] from items array is valid",
163 "data": [false, true],
164 "valid": true
165 },
166 {
167 "description": "[true, false] from items array is valid",
168 "data": [true, false],
169 "valid": true
170 },
171 {
172 "description": "[false, false] from items array is not valid",
173 "data": [false, false],
174 "valid": false
175 },
176 {
177 "description": "[true, true] from items array is not valid",
178 "data": [true, true],
179 "valid": false
180 },
181 {
182 "description": "unique array extended from [false, true] is valid",
183 "data": [false, true, "foo", "bar"],
184 "valid": true
185 },
186 {
187 "description": "unique array extended from [true, false] is valid",
188 "data": [true, false, "foo", "bar"],
189 "valid": true
190 },
191 {
192 "description": "non-unique array extended from [false, true] is not valid",
193 "data": [false, true, "foo", "foo"],
194 "valid": false
195 },
196 {
197 "description": "non-unique array extended from [true, false] is not valid",
198 "data": [true, false, "foo", "foo"],
199 "valid": false
200 }
201 ]
202 },
203 {
204 "description": "uniqueItems with an array of items and additionalItems=false",
205 "schema": {
206 "items": [{"type": "boolean"}, {"type": "boolean"}],
207 "uniqueItems": true,
208 "additionalItems": false
209 },
210 "tests": [
211 {
212 "description": "[false, true] from items array is valid",
213 "data": [false, true],
214 "valid": true
215 },
216 {
217 "description": "[true, false] from items array is valid",
218 "data": [true, false],
219 "valid": true
220 },
221 {
222 "description": "[false, false] from items array is not valid",
223 "data": [false, false],
224 "valid": false
225 },
226 {
227 "description": "[true, true] from items array is not valid",
228 "data": [true, true],
229 "valid": false
230 },
231 {
232 "description": "extra items are invalid even if unique",
233 "data": [false, true, null],
234 "valid": false
235 }
236 ]
237 },
238 {
239 "description": "uniqueItems=false validation",
240 "schema": { "uniqueItems": false },
241 "tests": [
242 {
243 "description": "unique array of integers is valid",
244 "data": [1, 2],
245 "valid": true
246 },
247 {
248 "description": "non-unique array of integers is valid",
249 "data": [1, 1],
250 "valid": true
251 },
252 {
253 "description": "numbers are unique if mathematically unequal",
254 "data": [1.0, 1.00, 1],
255 "valid": true
256 },
257 {
258 "description": "false is not equal to zero",
259 "data": [0, false],
260 "valid": true
261 },
262 {
263 "description": "true is not equal to one",
264 "data": [1, true],
265 "valid": true
266 },
267 {
268 "description": "unique array of objects is valid",
269 "data": [{"foo": "bar"}, {"foo": "baz"}],
270 "valid": true
271 },
272 {
273 "description": "non-unique array of objects is valid",
274 "data": [{"foo": "bar"}, {"foo": "bar"}],
275 "valid": true
276 },
277 {
278 "description": "unique array of nested objects is valid",
279 "data": [
280 {"foo": {"bar" : {"baz" : true}}},
281 {"foo": {"bar" : {"baz" : false}}}
282 ],
283 "valid": true
284 },
285 {
286 "description": "non-unique array of nested objects is valid",
287 "data": [
288 {"foo": {"bar" : {"baz" : true}}},
289 {"foo": {"bar" : {"baz" : true}}}
290 ],
291 "valid": true
292 },
293 {
294 "description": "unique array of arrays is valid",
295 "data": [["foo"], ["bar"]],
296 "valid": true
297 },
298 {
299 "description": "non-unique array of arrays is valid",
300 "data": [["foo"], ["foo"]],
301 "valid": true
302 },
303 {
304 "description": "1 and true are unique",
305 "data": [1, true],
306 "valid": true
307 },
308 {
309 "description": "0 and false are unique",
310 "data": [0, false],
311 "valid": true
312 },
313 {
314 "description": "unique heterogeneous types are valid",
315 "data": [{}, [1], true, null, 1],
316 "valid": true
317 },
318 {
319 "description": "non-unique heterogeneous types are valid",
320 "data": [{}, [1], true, null, {}, 1],
321 "valid": true
322 }
323 ]
324 },
325 {
326 "description": "uniqueItems=false with an array of items",
327 "schema": {
328 "items": [{"type": "boolean"}, {"type": "boolean"}],
329 "uniqueItems": false
330 },
331 "tests": [
332 {
333 "description": "[false, true] from items array is valid",
334 "data": [false, true],
335 "valid": true
336 },
337 {
338 "description": "[true, false] from items array is valid",
339 "data": [true, false],
340 "valid": true
341 },
342 {
343 "description": "[false, false] from items array is valid",
344 "data": [false, false],
345 "valid": true
346 },
347 {
348 "description": "[true, true] from items array is valid",
349 "data": [true, true],
350 "valid": true
351 },
352 {
353 "description": "unique array extended from [false, true] is valid",
354 "data": [false, true, "foo", "bar"],
355 "valid": true
356 },
357 {
358 "description": "unique array extended from [true, false] is valid",
359 "data": [true, false, "foo", "bar"],
360 "valid": true
361 },
362 {
363 "description": "non-unique array extended from [false, true] is valid",
364 "data": [false, true, "foo", "foo"],
365 "valid": true
366 },
367 {
368 "description": "non-unique array extended from [true, false] is valid",
369 "data": [true, false, "foo", "foo"],
370 "valid": true
371 }
372 ]
373 },
374 {
375 "description": "uniqueItems=false with an array of items and additionalItems=false",
376 "schema": {
377 "items": [{"type": "boolean"}, {"type": "boolean"}],
378 "uniqueItems": false,
379 "additionalItems": false
380 },
381 "tests": [
382 {
383 "description": "[false, true] from items array is valid",
384 "data": [false, true],
385 "valid": true
386 },
387 {
388 "description": "[true, false] from items array is valid",
389 "data": [true, false],
390 "valid": true
391 },
392 {
393 "description": "[false, false] from items array is valid",
394 "data": [false, false],
395 "valid": true
396 },
397 {
398 "description": "[true, true] from items array is valid",
399 "data": [true, true],
400 "valid": true
401 },
402 {
403 "description": "extra items are invalid even if unique",
404 "data": [false, true, null],
405 "valid": false
406 }
407 ]
408 }
409 ]