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
212 Err: ERROR: Misplaced byte-order mark, complain in Redmond at line 1:1
217 Err: ERROR: Zero bytes in strings are not supported at line 1:7
219 Name: Escaped surrogate
221 Out: "<f3><8f><b2><ba>"<0a>
223 Name: Escaped surrogate malformation 1
226 Err: ERROR: Escaped high surrogate codepoint must be followed by a low surrogate codepoint at line 1:8
228 Name: Escaped surrogate malformation 2
231 Err: ERROR: Invalid escaped surrogate codepoint at line 1:7
233 Name: Escaped low private-use character
236 Err: ERROR: Invalid escaped private-use character at line 1:7
238 Name: Escaped high private-use character
241 Err: ERROR: Invalid escaped private-use character at line 1:13
243 # Switch back to normal mode
244 Name: Invalid ASCII character
245 Run: ../obj/ucw-json/json-test -rw
248 Err: ERROR: Invalid character at line 1:1
256 Name: One-element array
260 Name: Two-element array
265 In: [[1,2],["a","b"]]
266 Out: [ [ 1, 2 ], [ "a", "b" ] ]
268 Name: Multi-line array
273 Out: [ "a", null, false, false ]
275 Name: Unterminated array 1
278 Err: ERROR: Comma or right bracket expected at line 2:0
280 Name: Unterminated array 2
283 Err: ERROR: Unterminated array at line 2:0
285 Name: Extra comma not allowed
288 Err: ERROR: Misplaced end of array at line 1:6
290 Name: Solitary comma not allowed
293 Err: ERROR: Misplaced comma at line 1:1
295 Name: Deeply nested array
296 In: [[[[[[[[[[]]]]]]]]]]
297 Out: [ [ [ [ [ [ [ [ [ [] ] ] ] ] ] ] ] ] ]
299 Name: Deeply unclosed array
302 Err: ERROR: Comma or right bracket expected at line 2:0
307 Err: ERROR: Comma or right bracket expected at line 1:5
315 Name: One-entry object
319 Name: Two-entry object
321 Out: { "a": 1, "b": 2 }
326 "b": { "x": true, "y": false }
328 Out: { "a": [ 1, 2 ], "b": { "x": true, "y": false } }
330 Name: Unterminated object 1
333 Err: ERROR: Unterminated object at line 2:0
335 Name: Unterminated object 2
338 Err: ERROR: Colon expected at line 2:0
340 Name: Unterminated object 3
343 Err: ERROR: Unterminated object at line 2:0
345 Name: Unterminated object 4
348 Err: ERROR: Unterminated object at line 2:0
350 Name: Extra comma not allowed in objects
353 Err: ERROR: Misplaced end of object at line 1:10
358 Err: ERROR: Object key must be a string at line 1:3
363 Err: ERROR: Key already set at line 1:14
365 Name: Missing object comma
368 Err: ERROR: Comma expected at line 1:10
370 ### Top-level problems ###
374 Err: ERROR: Empty input at line 1:0
376 Name: Multiple values
379 Err: ERROR: Only one top-level value allowed at line 1:4