Debian Codegraph @

spec/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json

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