Debian Codegraph @

share/tests/v1/const.json

raw
1 [
2 {
3 "description": "const validation",
4 "schema": {
5 "$schema": "https://json-schema.org/v1",
6 "const": 2
7 },
8 "tests": [
9 {
10 "description": "same value is valid",
11 "data": 2,
12 "valid": true
13 },
14 {
15 "description": "another value is invalid",
16 "data": 5,
17 "valid": false
18 },
19 {
20 "description": "another type is invalid",
21 "data": "a",
22 "valid": false
23 }
24 ]
25 },
26 {
27 "description": "const with object",
28 "schema": {
29 "$schema": "https://json-schema.org/v1",
30 "const": {"foo": "bar", "baz": "bax"}
31 },
32 "tests": [
33 {
34 "description": "same object is valid",
35 "data": {"foo": "bar", "baz": "bax"},
36 "valid": true
37 },
38 {
39 "description": "same object with different property order is valid",
40 "data": {"baz": "bax", "foo": "bar"},
41 "valid": true
42 },
43 {
44 "description": "another object is invalid",
45 "data": {"foo": "bar"},
46 "valid": false
47 },
48 {
49 "description": "another type is invalid",
50 "data": [1, 2],
51 "valid": false
52 }
53 ]
54 },
55 {
56 "description": "const with array",
57 "schema": {
58 "$schema": "https://json-schema.org/v1",
59 "const": [{ "foo": "bar" }]
60 },
61 "tests": [
62 {
63 "description": "same array is valid",
64 "data": [{"foo": "bar"}],
65 "valid": true
66 },
67 {
68 "description": "another array item is invalid",
69 "data": [2],
70 "valid": false
71 },
72 {
73 "description": "array with additional items is invalid",
74 "data": [1, 2, 3],
75 "valid": false
76 }
77 ]
78 },
79 {
80 "description": "const with null",
81 "schema": {
82 "$schema": "https://json-schema.org/v1",
83 "const": null
84 },
85 "tests": [
86 {
87 "description": "null is valid",
88 "data": null,
89 "valid": true
90 },
91 {
92 "description": "not null is invalid",
93 "data": 0,
94 "valid": false
95 }
96 ]
97 },
98 {
99 "description": "const with false does not match 0",
100 "schema": {
101 "$schema": "https://json-schema.org/v1",
102 "const": false
103 },
104 "tests": [
105 {
106 "description": "false is valid",
107 "data": false,
108 "valid": true
109 },
110 {
111 "description": "integer zero is invalid",
112 "data": 0,
113 "valid": false
114 },
115 {
116 "description": "float zero is invalid",
117 "data": 0.0,
118 "valid": false
119 }
120 ]
121 },
122 {
123 "description": "const with true does not match 1",
124 "schema": {
125 "$schema": "https://json-schema.org/v1",
126 "const": true
127 },
128 "tests": [
129 {
130 "description": "true is valid",
131 "data": true,
132 "valid": true
133 },
134 {
135 "description": "integer one is invalid",
136 "data": 1,
137 "valid": false
138 },
139 {
140 "description": "float one is invalid",
141 "data": 1.0,
142 "valid": false
143 }
144 ]
145 },
146 {
147 "description": "const with [false] does not match [0]",
148 "schema": {
149 "$schema": "https://json-schema.org/v1",
150 "const": [false]
151 },
152 "tests": [
153 {
154 "description": "[false] is valid",
155 "data": [false],
156 "valid": true
157 },
158 {
159 "description": "[0] is invalid",
160 "data": [0],
161 "valid": false
162 },
163 {
164 "description": "[0.0] is invalid",
165 "data": [0.0],
166 "valid": false
167 }
168 ]
169 },
170 {
171 "description": "const with [true] does not match [1]",
172 "schema": {
173 "$schema": "https://json-schema.org/v1",
174 "const": [true]
175 },
176 "tests": [
177 {
178 "description": "[true] is valid",
179 "data": [true],
180 "valid": true
181 },
182 {
183 "description": "[1] is invalid",
184 "data": [1],
185 "valid": false
186 },
187 {
188 "description": "[1.0] is invalid",
189 "data": [1.0],
190 "valid": false
191 }
192 ]
193 },
194 {
195 "description": "const with {\"a\": false} does not match {\"a\": 0}",
196 "schema": {
197 "$schema": "https://json-schema.org/v1",
198 "const": {"a": false}
199 },
200 "tests": [
201 {
202 "description": "{\"a\": false} is valid",
203 "data": {"a": false},
204 "valid": true
205 },
206 {
207 "description": "{\"a\": 0} is invalid",
208 "data": {"a": 0},
209 "valid": false
210 },
211 {
212 "description": "{\"a\": 0.0} is invalid",
213 "data": {"a": 0.0},
214 "valid": false
215 }
216 ]
217 },
218 {
219 "description": "const with {\"a\": true} does not match {\"a\": 1}",
220 "schema": {
221 "$schema": "https://json-schema.org/v1",
222 "const": {"a": true}
223 },
224 "tests": [
225 {
226 "description": "{\"a\": true} is valid",
227 "data": {"a": true},
228 "valid": true
229 },
230 {
231 "description": "{\"a\": 1} is invalid",
232 "data": {"a": 1},
233 "valid": false
234 },
235 {
236 "description": "{\"a\": 1.0} is invalid",
237 "data": {"a": 1.0},
238 "valid": false
239 }
240 ]
241 },
242 {
243 "description": "const with 0 does not match other zero-like types",
244 "schema": {
245 "$schema": "https://json-schema.org/v1",
246 "const": 0
247 },
248 "tests": [
249 {
250 "description": "false is invalid",
251 "data": false,
252 "valid": false
253 },
254 {
255 "description": "integer zero is valid",
256 "data": 0,
257 "valid": true
258 },
259 {
260 "description": "float zero is valid",
261 "data": 0.0,
262 "valid": true
263 },
264 {
265 "description": "empty object is invalid",
266 "data": {},
267 "valid": false
268 },
269 {
270 "description": "empty array is invalid",
271 "data": [],
272 "valid": false
273 },
274 {
275 "description": "empty string is invalid",
276 "data": "",
277 "valid": false
278 }
279 ]
280 },
281 {
282 "description": "const with 1 does not match true",
283 "schema": {
284 "$schema": "https://json-schema.org/v1",
285 "const": 1
286 },
287 "tests": [
288 {
289 "description": "true is invalid",
290 "data": true,
291 "valid": false
292 },
293 {
294 "description": "integer one is valid",
295 "data": 1,
296 "valid": true
297 },
298 {
299 "description": "float one is valid",
300 "data": 1.0,
301 "valid": true
302 }
303 ]
304 },
305 {
306 "description": "const with -2.0 matches integer and float types",
307 "schema": {
308 "$schema": "https://json-schema.org/v1",
309 "const": -2.0
310 },
311 "tests": [
312 {
313 "description": "integer -2 is valid",
314 "data": -2,
315 "valid": true
316 },
317 {
318 "description": "integer 2 is invalid",
319 "data": 2,
320 "valid": false
321 },
322 {
323 "description": "float -2.0 is valid",
324 "data": -2.0,
325 "valid": true
326 },
327 {
328 "description": "float 2.0 is invalid",
329 "data": 2.0,
330 "valid": false
331 },
332 {
333 "description": "float -2.00001 is invalid",
334 "data": -2.00001,
335 "valid": false
336 }
337 ]
338 },
339 {
340 "description": "float and integers are equal up to 64-bit representation limits",
341 "schema": {
342 "$schema": "https://json-schema.org/v1",
343 "const": 9007199254740992
344 },
345 "tests": [
346 {
347 "description": "integer is valid",
348 "data": 9007199254740992,
349 "valid": true
350 },
351 {
352 "description": "integer minus one is invalid",
353 "data": 9007199254740991,
354 "valid": false
355 },
356 {
357 "description": "float is valid",
358 "data": 9007199254740992.0,
359 "valid": true
360 },
361 {
362 "description": "float minus one is invalid",
363 "data": 9007199254740991.0,
364 "valid": false
365 }
366 ]
367 },
368 {
369 "description": "nul characters in strings",
370 "schema": {
371 "$schema": "https://json-schema.org/v1",
372 "const": "hello\u0000there"
373 },
374 "tests": [
375 {
376 "description": "match string with nul",
377 "data": "hello\u0000there",
378 "valid": true
379 },
380 {
381 "description": "do not match string lacking nul",
382 "data": "hellothere",
383 "valid": false
384 }
385 ]
386 },
387 {
388 "description": "characters with the same visual representation but different codepoint",
389 "schema": {
390 "$schema": "https://json-schema.org/v1",
391 "const": "μ",
392 "$comment": "U+03BC"
393 },
394 "tests": [
395 {
396 "description": "character uses the same codepoint",
397 "data": "μ",
398 "comment": "U+03BC",
399 "valid": true
400 },
401 {
402 "description": "character looks the same but uses a different codepoint",
403 "data": "µ",
404 "comment": "U+00B5",
405 "valid": false
406 }
407 ]
408 },
409 {
410 "description": "characters with the same visual representation, but different number of codepoints",
411 "schema": {
412 "$schema": "https://json-schema.org/v1",
413 "const": "ä",
414 "$comment": "U+00E4"
415 },
416 "tests": [
417 {
418 "description": "character uses the same codepoint",
419 "data": "ä",
420 "comment": "U+00E4",
421 "valid": true
422 },
423 {
424 "description": "character looks the same but uses combining marks",
425 "data": "ä",
426 "comment": "a, U+0308",
427 "valid": false
428 }
429 ]
430 }
431 ]