1 # Tests for the JSON library
2 # (c) 2015 Martin Mares <mj@ucw.cz>
7 Run: ../obj/ucw-json/json-test -rw
19 Name: Invalid literal 1
22 Err: ERROR: Invalid literal name at line 1:8
24 Name: Invalid literal 2
25 In: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
27 Err: ERROR: Invalid literal name at line 1:101
43 # The largest number guaranteed to be precise by RFC 7159
48 Name: Fractional number 1
52 Name: Fractional number 2
56 Name: Number in scientific notation 1
60 Name: Number in scientific notation 2
64 Name: Number in scientific notation 3
68 Name: No leading zero allowed
71 Err: ERROR: Malformed number: leading zero at line 1:2
73 Name: Bare sign is not a number
76 Err: ERROR: Malformed number: just minus at line 1:2
78 Name: No leading decimal point allowed
81 Err: ERROR: Numbers must start with a digit at line 1:1
83 Name: Digits after decimal point required
86 Err: ERROR: Malformed number: no digits after decimal point at line 1:6
88 Name: Exponent part must be non-empty 1
91 Err: ERROR: Malformed number: empty exponent at line 1:3
93 Name: Exponent part must be non-empty 2
96 Err: ERROR: Malformed number: empty exponent at line 1:4
98 Name: Number out of range
101 Err: ERROR: Number out of range at line 1:10
117 Name: Unterminated string
120 Err: ERROR: Unterminated string at line 1:10
122 Name: Multi-line string
126 Err: ERROR: Unterminated string at line 1:6
128 # Some characters are written as \uXXXX on output, which is correct
129 Name: Escaped characters
130 In: "\"\\\/\b\f\n\r\t"
131 Out: "\"\\/\u0008\u000c\n\r\t"
133 Name: Improper escaped characters
136 Err: ERROR: Invalid backslash sequence in string at line 1:3
138 Name: Unicode escapes
139 In: "\u0041\u010d\u010D\u0001"
142 Name: Improper Unicode escapes 1
145 Err: ERROR: Invalid Unicode escape sequence at line 1:4
147 Name: Improper Unicode escapes 2
150 Err: ERROR: Invalid Unicode escape sequence at line 1:4
152 Name: Improper Unicode escapes 3
155 Err: ERROR: Invalid Unicode escape sequence at line 1:7
157 ### Unicode magic ###
160 Name: Control characters 1
161 Run: ../obj/ucw-json/json-test -RW
164 Err: ERROR: Invalid control character in string at line 1:2
166 # Surprisingly, DEL is not
167 Name: Control characters 2
172 Name: UTF-8 outside BMP
173 In: "<f0><b1><88><b4>"
174 Out: "<f0><b1><88><b4>"<0a>
176 Name: Private use characters in BMP
179 Err: ERROR: Invalid private-use character in string at line 1:2
181 Name: UTF-8 outside BMP
182 In: "<f0><b1><88><b4>"
183 Out: "<f0><b1><88><b4>"<0a>
185 Name: Private use characters outside BMP
186 In: "<f3><b0><80><80>"
188 Err: ERROR: Invalid private-use character in string at line 1:2
191 Name: UTF-8 outside UCS
192 In: "<f8><bf><b0><80><80>"
194 Err: ERROR: Invalid non-Unicode character in string at line 1:2
197 Name: UTF-8 surrogate 1
200 Err: ERROR: Invalid surrogate character in string at line 1:2
203 Name: UTF-8 surrogate 2
206 Err: ERROR: Invalid surrogate character in string at line 1:2
208 # Denormalized U+07FF
209 Name: UTF-8 denormalized
212 Err: ERROR: Malformed UTF-8 character at line 1:1
218 Err: ERROR: Misplaced byte-order mark, complain in Redmond at line 1:1
223 Err: ERROR: Zero bytes in strings are not supported at line 1:7
225 Name: Escaped surrogate
227 Out: "<f3><8f><b2><ba>"<0a>
229 Name: Escaped surrogate malformation 1
232 Err: ERROR: Escaped high surrogate codepoint must be followed by a low surrogate codepoint at line 1:8
234 Name: Escaped surrogate malformation 2
237 Err: ERROR: Invalid escaped surrogate codepoint at line 1:7
239 Name: Escaped low private-use character
242 Err: ERROR: Invalid escaped private-use character at line 1:7
244 Name: Escaped high private-use character
247 Err: ERROR: Invalid escaped private-use character at line 1:13
249 # Switch back to normal mode
250 Name: Invalid ASCII character
251 Run: ../obj/ucw-json/json-test -rw
254 Err: ERROR: Invalid character at line 1:1
262 Name: One-element array
266 Name: Two-element array
271 In: [[1,2],["a","b"]]
272 Out: [ [ 1, 2 ], [ "a", "b" ] ]
274 Name: Multi-line array
279 Out: [ "a", null, false, false ]
281 Name: Unterminated array 1
284 Err: ERROR: Comma or right bracket expected at line 2:0
286 Name: Unterminated array 2
289 Err: ERROR: Unterminated array at line 2:0
291 Name: Extra comma not allowed
294 Err: ERROR: Misplaced end of array at line 1:6
296 Name: Solitary comma not allowed
299 Err: ERROR: Misplaced comma at line 1:1
301 Name: Deeply nested array
302 In: [[[[[[[[[[]]]]]]]]]]
303 Out: [ [ [ [ [ [ [ [ [ [] ] ] ] ] ] ] ] ] ]
305 Name: Deeply unclosed array
308 Err: ERROR: Comma or right bracket expected at line 2:0
313 Err: ERROR: Comma or right bracket expected at line 1:5
321 Name: One-entry object
325 Name: Two-entry object
327 Out: { "a": 1, "b": 2 }
332 "b": { "x": true, "y": false }
334 Out: { "a": [ 1, 2 ], "b": { "x": true, "y": false } }
336 Name: Unterminated object 1
339 Err: ERROR: Unterminated object at line 2:0
341 Name: Unterminated object 2
344 Err: ERROR: Colon expected at line 2:0
346 Name: Unterminated object 3
349 Err: ERROR: Unterminated object at line 2:0
351 Name: Unterminated object 4
354 Err: ERROR: Unterminated object at line 2:0
356 Name: Extra comma not allowed in objects
359 Err: ERROR: Misplaced end of object at line 1:10
364 Err: ERROR: Object key must be a string at line 1:3
369 Err: ERROR: Key already set at line 1:14
371 Name: Missing object comma
374 Err: ERROR: Comma expected at line 1:10
376 ### Top-level problems ###
380 Err: ERROR: Empty input at line 1:0
382 Name: Multiple values
385 Err: ERROR: Only one top-level value allowed at line 1:4
387 ### Streaming interface ###
390 Run: ../obj/ucw-json/json-test -s
391 In: 123 [true, false] "Rincewind"