summaryrefslogtreecommitdiff
path: root/json/tests/draft6/const.json
blob: c53d04d95f041fb5ba34c66f69e61083b01a997e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
[
    {
        "description": "const validation",
        "schema": {"const": 2},
        "tests": [
            {
                "description": "same value is valid",
                "data": 2,
                "valid": true
            },
            {
                "description": "another value is invalid",
                "data": 5,
                "valid": false
            },
            {
                "description": "another type is invalid",
                "data": "a",
                "valid": false
            }
        ]
    },
    {
        "description": "const with object",
        "schema": {"const": {"foo": "bar", "baz": "bax"}},
        "tests": [
            {
                "description": "same object is valid",
                "data": {"foo": "bar", "baz": "bax"},
                "valid": true
            },
            {
                "description": "same object with different property order is valid",
                "data": {"baz": "bax", "foo": "bar"},
                "valid": true
            },
            {
                "description": "another object is invalid",
                "data": {"foo": "bar"},
                "valid": false
            },
            {
                "description": "another type is invalid",
                "data": [1, 2],
                "valid": false
            }
        ]
    },
    {
        "description": "const with array",
        "schema": {"const": [{ "foo": "bar" }]},
        "tests": [
            {
                "description": "same array is valid",
                "data": [{"foo": "bar"}],
                "valid": true
            },
            {
                "description": "another array item is invalid",
                "data": [2],
                "valid": false
            },
            {
                "description": "array with additional items is invalid",
                "data": [1, 2, 3],
                "valid": false
            }
        ]
    },
    {
        "description": "const with null",
        "schema": {"const": null},
        "tests": [
            {
                "description": "null is valid",
                "data": null,
                "valid": true
            },
            {
                "description": "not null is invalid",
                "data": 0,
                "valid": false
            }
        ]
    },
    {
        "description": "const with false does not match 0",
        "schema": {"const": false},
        "tests": [
            {
                "description": "false is valid",
                "data": false,
                "valid": true
            },
            {
                "description": "integer zero is invalid",
                "data": 0,
                "valid": false
            },
            {
                "description": "float zero is invalid",
                "data": 0.0,
                "valid": false
            }
        ]
    },
    {
        "description": "const with true does not match 1",
        "schema": {"const": true},
        "tests": [
            {
                "description": "true is valid",
                "data": true,
                "valid": true
            },
            {
                "description": "integer one is invalid",
                "data": 1,
                "valid": false
            },
            {
                "description": "float one is invalid",
                "data": 1.0,
                "valid": false
            }
        ]
    },
    {
        "description": "const with 0 does not match other zero-like types",
        "schema": {"const": 0},
        "tests": [
            {
                "description": "false is invalid",
                "data": false,
                "valid": false
            },
            {
                "description": "integer zero is valid",
                "data": 0,
                "valid": true
            },
            {
                "description": "float zero is valid",
                "data": 0.0,
                "valid": true
            },
            {
                "description": "empty object is invalid",
                "data": {},
                "valid": false
            },
            {
                "description": "empty array is invalid",
                "data": [],
                "valid": false
            },
            {
                "description": "empty string is invalid",
                "data": "",
                "valid": false
            }
        ]
    },
    {
        "description": "const with 1 does not match true",
        "schema": {"const": 1},
        "tests": [
            {
                "description": "true is invalid",
                "data": true,
                "valid": false
            },
            {
                "description": "integer one is valid",
                "data": 1,
                "valid": true
            },
            {
                "description": "float one is valid",
                "data": 1.0,
                "valid": true
            }
        ]
    },
    {
        "description": "const with -2.0 matches integer and float types",
        "schema": {"const": -2.0},
        "tests": [
            {
                "description": "integer -2 is valid",
                "data": -2,
                "valid": true
            },
            {
                "description": "integer 2 is invalid",
                "data": 2,
                "valid": false
            },
            {
                "description": "float -2.0 is valid",
                "data": -2.0,
                "valid": true
            },
            {
                "description": "float 2.0 is invalid",
                "data": 2.0,
                "valid": false
            },
            {
                "description": "float -2.00001 is invalid",
                "data": -2.00001,
                "valid": false
            }
        ]
    },
    {
        "description": "float and integers are equal up to 64-bit representation limits",
        "schema": {"const": 9007199254740992},
        "tests": [
            {
                "description": "integer is valid",
                "data": 9007199254740992,
                "valid": true
            },
            {
                "description": "integer minus one is invalid",
                "data": 9007199254740991,
                "valid": false
            },
            {
                "description": "float is valid",
                "data": 9007199254740992.0,
                "valid": true
            },
            {
                "description": "float minus one is invalid",
                "data": 9007199254740991.0,
                "valid": false
            }
        ]
    },
    {
        "description": "nul characters in strings",
        "schema": { "const": "hello\u0000there" },
        "tests": [
            {
                "description": "match string with nul",
                "data": "hello\u0000there",
                "valid": true
            },
            {
                "description": "do not match string lacking nul",
                "data": "hellothere",
                "valid": false
            }
        ]
    }
]