-
Notifications
You must be signed in to change notification settings - Fork 3
/
draft-tjson-examples.txt
426 lines (310 loc) · 9.54 KB
/
draft-tjson-examples.txt
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
#
# [DRAFT] Annotated TJSON examples intended for testing TJSON parsers
#
# Revision: 24 (bump this when making changes to this file)
#
# Syntax used in this file:
#
# - Any line beginning with a '#' is a comment and should be ignored
# - Examples are delimited by a line containing only '-----' (5 hyphen characters)
# - This file should begin/end with '-----' with only comments allowed before/after
# the leading and trailing '-----' respectively (i.e. this comment block)
# - Each example consists of TOML metadata and an example, separated by a blank line
#
# Example metadata syntax:
#
# - name = "Name of this example"
# - description = "A more extended description of what this example tests"
# - result = "success" | "error"
#
-----
name = "Empty Object"
description = "Objects are allowed as a toplevel value and can be empty"
result = "success"
{}
-----
name = "Object with UTF-8 String Key"
description = "Strings are allowed as names of object members"
result = "success"
{"example:s":"foobar"}
-----
name = "Invalid Object with Untagged Name"
description = "All strings in TJSON must be tagged"
result = "error"
{"example":"foobar"}
-----
name = "Invalid Object with Empty Tag"
description = "All strings in TJSON must be tagged"
result = "error"
{"example:":"foobar"}
-----
name = "Invalid Object with Repeated Member Names"
description = "Names of the members of objects must be distinct"
result = "error"
{"example:i":"1","example:i":"2"}
-----
name = "Invalid Object with Repeated Member Names and Values"
description = "Names of the members of objects must be distinct"
result = "error"
{"example:i":"1","example:i":"1"}
-----
name = "Invalid Object with Trailing Comma"
description = "Trailing commas are explicitly allowed in JSON, let alone TJSON"
result = "error"
{"example1:i":"1","example2:i":"2",}
-----
name = "Invalid Toplevel Array"
description = "Arrays are NOT allowed as a toplevel value"
result = "error"
[]
-----
name = "Array of integers"
description = "Arrays are parameterized by the types of their contents"
result = "success"
{"example:A<i>": ["1", "2", "3"]}
-----
name = "Array of objects"
description = "Objects are the only allowed terminal non-scalar"
result = "success"
{"example:A<O>": [{"a:i": "1"}, {"b:i": "2"}]}
-----
name = "Empty array"
description = "Empty arrays are allowed to omit the type parameter"
result = "success"
{"example:A<>": []}
-----
name = "Array with missing type parameter"
description = "Type parameters are mandatory for non-empty arrays"
result = "error"
{"example:A<>": ["1", "2", "3"]}
-----
name = "Multidimensional array of integers"
description = "Arrays can contain other arrays"
result = "success"
{"example:A<A<i>>": [["1", "2"], ["3", "4"], ["5", "6"]]}
-----
name = "Set of integers"
description = "Sets are parameterized by the types of their contents"
result = "success"
{"example:S<i>": ["1", "2", "3"]}
-----
name = "Invalid set of integers with duplicate members"
description = "The members of sets MUST be unique or the parser MUST reject the document"
result = "error"
{"example:S<i>": ["1", "1"]}
-----
name = "Set of objects"
description = "Objects are the only allowed terminal non-scalar"
result = "success"
{"example:A<O>": [{"a:i": "1"}, {"b:i": "2"}]}
-----
name = "Invalid set of duplicate objects"
description = "The members of sets MUST be unique or the parser MUST reject the document"
result = "error"
{"example:S<O>": [{"a:i": "1"}, {"a:i": "1"}]}
-----
name = "Empty set"
description = "Empty sets are allowed to omit the type parameter"
result = "success"
{"example:S<>": []}
-----
name = "Set with missing type parameter"
description = "Type parameters are mandatory for non-empty sets"
result = "error"
{"example:S<>": ["1", "2", "3"]}
-----
name = "Set containing arrays of integers"
description = "Sets can contain arrays"
result = "success"
{"example:S<A<i>>": [["1", "2"], ["3", "4"], ["5", "6"]]}
-----
name = "Invalid set containing duplicate arrays"
description = "Sets containing arrays must contain unique arrays"
result = "error"
{"example:S<A<i>>": [["1", "2"], ["1", "2"]]}
-----
name = "Base16 Binary Data"
description = "Base16 data begins with the 'b16:' prefix"
result = "success"
{"example:d16":"48656c6c6f2c20776f726c6421"}
-----
name = "Invalid Base16 Binary Data with bad case"
description = "Base16 data MUST be lower case"
result = "error"
{"example:d16":"48656C6C6F2C20776F726C6421"}
-----
name = "Invalid Base16 Binary Data"
description = "Base16 data must be valid hexadecimal"
result = "error"
{"example:d16":"This is not a valid hexadecimal string"}
-----
name = "Base32 Binary Data"
description = "Base32 data begins with the 'b32:' prefix"
result = "success"
{"example:d32":"jbswy3dpfqqho33snrscc"}
-----
name = "Invalid Base32 Binary Data with bad case"
description = "Base32 data MUST be lower case"
result = "error"
{"example:d32":"JBSWY3DPFQQHO33SNRSCC"}
-----
name = "Invalid Base32 Binary Data with padding"
description = "Base64 data MUST NOT include padding"
result = "error"
{"example:d32":"jbswy3dpfqqho33snrscc==="}
-----
name = "Invalid Base32 Binary Data"
description = "Base32 data must be valid"
result = "error"
{"example:d32":"This is not a valid base32 string"}
-----
name = "Base64url Binary Data"
description = "Base64 data begins with the 'b64:' prefix"
result = "success"
{"example:d64":"SGVsbG8sIHdvcmxkIQ"}
-----
name = "Invalid Base64url Binary Data with padding"
description = "Base64 data MUST NOT include padding"
result = "error"
{"example:d64":"SGVsbG8sIHdvcmxkIQ=="}
-----
name = "Invalid Base64url Binary Data with non-URL safe characters"
description = "Traditional Base64 is expressly disallowed"
result = "error"
{"example:d64":"+/+/"}
-----
name = "Invalid Base64url Binary Data"
description = "Garbage data MUST be rejected"
result = "error"
{"example:d64":"This is not a valid base64url string"}
-----
name = "Signed Integer"
description = "Signed integers are represented as tagged strings"
result = "success"
{"example:i":"42"}
-----
name = "Signed Integer Range Test"
description = "Signed integers should support the full 64-bit range"
result = "success"
{"min:i":"-9223372036854775808", "max:i":"9223372036854775807"}
-----
name = "Oversized Signed Integer Test"
description = "Values larger than can be represented by a signed 64-bit integer MUST be rejected"
result = "error"
{"oversize:i":"9223372036854775808"}
-----
name = "Undersized Signed Integer Test"
description = "Values smaller than can be represented by a signed 64-bit integer MUST be rejected"
result = "error"
{"undersize:i":"-9223372036854775809"}
-----
name = "Invalid Signed Integer"
description = "Garbage data after the integer tag should be rejected"
result = "error"
{"invalid:i":"This is not a valid integer"}
-----
name = "Unsigned Integer"
description = "Unsigned integers are represented as tagged strings"
result = "success"
{"example:u":"42"}
-----
name = "Unsigned Integer Range Test"
description = "Unsigned integers should support the full 64-bit range"
result = "success"
{"maxint:u":"18446744073709551615"}
-----
name = "Oversized Unsigned Integer Test"
description = "Values larger than can be represented by an unsigned 64-bit integer MUST be rejected"
result = "error"
{"oversized:u":"18446744073709551616"}
-----
name = "Negative Unsigned Integer Test"
description = "Unsigned integers cannot be negative"
result = "error"
{"negative:u":"-1"}
-----
name = "Invalid Unsigned Integer"
description = "Garbage data after the integer tag should be rejected"
result = "error"
{"invalid:u":"This is not a valid integer"}
-----
name = "Floating Point"
description = "A valid floating point"
result = "success"
{"float:f":1.23}
-----
name = "Invalid Quoted Floating Point"
description = "Floating point values MUST NOT be quoted"
result = "error"
{"float:f":"1.23"}
-----
name = "Timestamp"
description = "A valid RFC3339 timestamp example"
result = "success"
{"example:t":"2016-10-02T07:31:51Z"}
-----
name = "Timestamp With Invalid Time Zone"
description = "All timestamps must be in the UTC ('Z') time zone"
result = "error"
{"invalid:t":"2016-10-02T07:31:51-08:00"}
-----
name = "Invalid Timestamp"
description = "Garbage data after the timestamp tag MUST be rejected"
result = "error"
{"invalid:t":"This is not a valid timestamp"}
-----
name = "True Boolean Value"
description = "True is allowed as a TJSON value"
result = "success"
{"example:b": true}
-----
name = "False Boolean Value"
description = "False is allowed as a TJSON value"
result = "success"
{"example:b": false}
-----
name = "Null Boolean Value"
description = "Null is disallowed as a TJSON value"
result = "error"
{"example:b": null}
-----
name = "Null Object"
description = "Null is disallowed as a TJSON object"
result = "error"
{"example:O": null}
-----
name = "Null Array"
description = "Null is disallowed as a TJSON array"
result = "error"
{"example:A<O>": [null]}
-----
name = "Null String"
description = "Null is disallowed as a TJSON string"
result = "error"
{"example:s": null}
-----
name = "Null Binary Data"
description = "Null is disallowed as a TJSON binary"
result = "error"
{"example:d": null}
-----
name = "Null Integer"
description = "Null is disallowed as a TJSON integer"
result = "error"
{"example:i": null}
-----
name = "Null Floating Point"
description = "Null is disallowed as a TJSON floating point"
result = "error"
{"example:f": null}
-----
name = "Null Unsigned"
description = "Null is disallowed as a TJSON unsigned integer"
result = "error"
{"example:u": null}
-----
name = "Null Timestamp"
description = "Null is disallowed as a TJSON timestamp"
result = "error"
{"example:t": null}
-----