| 1 | //! This file was generated by _generate_JSONTestSuite.zig |
| 2 | //! These test cases are sourced from: https://github.com/nst/JSONTestSuite |
| 3 | const ok = @import("./test.zig").ok; |
| 4 | const err = @import("./test.zig").err; |
| 5 | const any = @import("./test.zig").any; |
| 6 | |
| 7 | test "i_number_double_huge_neg_exp.json" { |
| 8 | try any("[123.456e-789]"); |
| 9 | } |
| 10 | test "i_number_huge_exp.json" { |
| 11 | try any("[0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006]"); |
| 12 | } |
| 13 | test "i_number_neg_int_huge_exp.json" { |
| 14 | try any("[-1e+9999]"); |
| 15 | } |
| 16 | test "i_number_pos_double_huge_exp.json" { |
| 17 | try any("[1.5e+9999]"); |
| 18 | } |
| 19 | test "i_number_real_neg_overflow.json" { |
| 20 | try any("[-123123e100000]"); |
| 21 | } |
| 22 | test "i_number_real_pos_overflow.json" { |
| 23 | try any("[123123e100000]"); |
| 24 | } |
| 25 | test "i_number_real_underflow.json" { |
| 26 | try any("[123e-10000000]"); |
| 27 | } |
| 28 | test "i_number_too_big_neg_int.json" { |
| 29 | try any("[-123123123123123123123123123123]"); |
| 30 | } |
| 31 | test "i_number_too_big_pos_int.json" { |
| 32 | try any("[100000000000000000000]"); |
| 33 | } |
| 34 | test "i_number_very_big_negative_int.json" { |
| 35 | try any("[-237462374673276894279832749832423479823246327846]"); |
| 36 | } |
| 37 | test "i_object_key_lone_2nd_surrogate.json" { |
| 38 | try any("{\"\\uDFAA\":0}"); |
| 39 | } |
| 40 | test "i_string_1st_surrogate_but_2nd_missing.json" { |
| 41 | try any("[\"\\uDADA\"]"); |
| 42 | } |
| 43 | test "i_string_1st_valid_surrogate_2nd_invalid.json" { |
| 44 | try any("[\"\\uD888\\u1234\"]"); |
| 45 | } |
| 46 | test "i_string_UTF-16LE_with_BOM.json" { |
| 47 | try any("\xff\xfe[\x00\"\x00\xe9\x00\"\x00]\x00"); |
| 48 | } |
| 49 | test "i_string_UTF-8_invalid_sequence.json" { |
| 50 | try any("[\"\xe6\x97\xa5\xd1\x88\xfa\"]"); |
| 51 | } |
| 52 | test "i_string_UTF8_surrogate_U+D800.json" { |
| 53 | try any("[\"\xed\xa0\x80\"]"); |
| 54 | } |
| 55 | test "i_string_incomplete_surrogate_and_escape_valid.json" { |
| 56 | try any("[\"\\uD800\\n\"]"); |
| 57 | } |
| 58 | test "i_string_incomplete_surrogate_pair.json" { |
| 59 | try any("[\"\\uDd1ea\"]"); |
| 60 | } |
| 61 | test "i_string_incomplete_surrogates_escape_valid.json" { |
| 62 | try any("[\"\\uD800\\uD800\\n\"]"); |
| 63 | } |
| 64 | test "i_string_invalid_lonely_surrogate.json" { |
| 65 | try any("[\"\\ud800\"]"); |
| 66 | } |
| 67 | test "i_string_invalid_surrogate.json" { |
| 68 | try any("[\"\\ud800abc\"]"); |
| 69 | } |
| 70 | test "i_string_invalid_utf-8.json" { |
| 71 | try any("[\"\xff\"]"); |
| 72 | } |
| 73 | test "i_string_inverted_surrogates_U+1D11E.json" { |
| 74 | try any("[\"\\uDd1e\\uD834\"]"); |
| 75 | } |
| 76 | test "i_string_iso_latin_1.json" { |
| 77 | try any("[\"\xe9\"]"); |
| 78 | } |
| 79 | test "i_string_lone_second_surrogate.json" { |
| 80 | try any("[\"\\uDFAA\"]"); |
| 81 | } |
| 82 | test "i_string_lone_utf8_continuation_byte.json" { |
| 83 | try any("[\"\x81\"]"); |
| 84 | } |
| 85 | test "i_string_not_in_unicode_range.json" { |
| 86 | try any("[\"\xf4\xbf\xbf\xbf\"]"); |
| 87 | } |
| 88 | test "i_string_overlong_sequence_2_bytes.json" { |
| 89 | try any("[\"\xc0\xaf\"]"); |
| 90 | } |
| 91 | test "i_string_overlong_sequence_6_bytes.json" { |
| 92 | try any("[\"\xfc\x83\xbf\xbf\xbf\xbf\"]"); |
| 93 | } |
| 94 | test "i_string_overlong_sequence_6_bytes_null.json" { |
| 95 | try any("[\"\xfc\x80\x80\x80\x80\x80\"]"); |
| 96 | } |
| 97 | test "i_string_truncated-utf-8.json" { |
| 98 | try any("[\"\xe0\xff\"]"); |
| 99 | } |
| 100 | test "i_string_utf16BE_no_BOM.json" { |
| 101 | try any("\x00[\x00\"\x00\xe9\x00\"\x00]"); |
| 102 | } |
| 103 | test "i_string_utf16LE_no_BOM.json" { |
| 104 | try any("[\x00\"\x00\xe9\x00\"\x00]\x00"); |
| 105 | } |
| 106 | test "i_structure_500_nested_arrays.json" { |
| 107 | try any(&@as([500]u8, @splat('[')) ++ &@as([500]u8, @splat(']'))); |
| 108 | } |
| 109 | test "i_structure_UTF-8_BOM_empty_object.json" { |
| 110 | try any("\xef\xbb\xbf{}"); |
| 111 | } |
| 112 | test "n_array_1_true_without_comma.json" { |
| 113 | try err("[1 true]"); |
| 114 | } |
| 115 | test "n_array_a_invalid_utf8.json" { |
| 116 | try err("[a\xe5]"); |
| 117 | } |
| 118 | test "n_array_colon_instead_of_comma.json" { |
| 119 | try err("[\"\": 1]"); |
| 120 | } |
| 121 | test "n_array_comma_after_close.json" { |
| 122 | try err("[\"\"],"); |
| 123 | } |
| 124 | test "n_array_comma_and_number.json" { |
| 125 | try err("[,1]"); |
| 126 | } |
| 127 | test "n_array_double_comma.json" { |
| 128 | try err("[1,,2]"); |
| 129 | } |
| 130 | test "n_array_double_extra_comma.json" { |
| 131 | try err("[\"x\",,]"); |
| 132 | } |
| 133 | test "n_array_extra_close.json" { |
| 134 | try err("[\"x\"]]"); |
| 135 | } |
| 136 | test "n_array_extra_comma.json" { |
| 137 | try err("[\"\",]"); |
| 138 | } |
| 139 | test "n_array_incomplete.json" { |
| 140 | try err("[\"x\""); |
| 141 | } |
| 142 | test "n_array_incomplete_invalid_value.json" { |
| 143 | try err("[x"); |
| 144 | } |
| 145 | test "n_array_inner_array_no_comma.json" { |
| 146 | try err("[3[4]]"); |
| 147 | } |
| 148 | test "n_array_invalid_utf8.json" { |
| 149 | try err("[\xff]"); |
| 150 | } |
| 151 | test "n_array_items_separated_by_semicolon.json" { |
| 152 | try err("[1:2]"); |
| 153 | } |
| 154 | test "n_array_just_comma.json" { |
| 155 | try err("[,]"); |
| 156 | } |
| 157 | test "n_array_just_minus.json" { |
| 158 | try err("[-]"); |
| 159 | } |
| 160 | test "n_array_missing_value.json" { |
| 161 | try err("[ , \"\"]"); |
| 162 | } |
| 163 | test "n_array_newlines_unclosed.json" { |
| 164 | try err("[\"a\",\n4\n,1,"); |
| 165 | } |
| 166 | test "n_array_number_and_comma.json" { |
| 167 | try err("[1,]"); |
| 168 | } |
| 169 | test "n_array_number_and_several_commas.json" { |
| 170 | try err("[1,,]"); |
| 171 | } |
| 172 | test "n_array_spaces_vertical_tab_formfeed.json" { |
| 173 | try err("[\"\x0ba\"\\f]"); |
| 174 | } |
| 175 | test "n_array_star_inside.json" { |
| 176 | try err("[*]"); |
| 177 | } |
| 178 | test "n_array_unclosed.json" { |
| 179 | try err("[\"\""); |
| 180 | } |
| 181 | test "n_array_unclosed_trailing_comma.json" { |
| 182 | try err("[1,"); |
| 183 | } |
| 184 | test "n_array_unclosed_with_new_lines.json" { |
| 185 | try err("[1,\n1\n,1"); |
| 186 | } |
| 187 | test "n_array_unclosed_with_object_inside.json" { |
| 188 | try err("[{}"); |
| 189 | } |
| 190 | test "n_incomplete_false.json" { |
| 191 | try err("[fals]"); |
| 192 | } |
| 193 | test "n_incomplete_null.json" { |
| 194 | try err("[nul]"); |
| 195 | } |
| 196 | test "n_incomplete_true.json" { |
| 197 | try err("[tru]"); |
| 198 | } |
| 199 | test "n_multidigit_number_then_00.json" { |
| 200 | try err("123\x00"); |
| 201 | } |
| 202 | test "n_number_++.json" { |
| 203 | try err("[++1234]"); |
| 204 | } |
| 205 | test "n_number_+1.json" { |
| 206 | try err("[+1]"); |
| 207 | } |
| 208 | test "n_number_+Inf.json" { |
| 209 | try err("[+Inf]"); |
| 210 | } |
| 211 | test "n_number_-01.json" { |
| 212 | try err("[-01]"); |
| 213 | } |
| 214 | test "n_number_-1.0..json" { |
| 215 | try err("[-1.0.]"); |
| 216 | } |
| 217 | test "n_number_-2..json" { |
| 218 | try err("[-2.]"); |
| 219 | } |
| 220 | test "n_number_-NaN.json" { |
| 221 | try err("[-NaN]"); |
| 222 | } |
| 223 | test "n_number_.-1.json" { |
| 224 | try err("[.-1]"); |
| 225 | } |
| 226 | test "n_number_.2e-3.json" { |
| 227 | try err("[.2e-3]"); |
| 228 | } |
| 229 | test "n_number_0.1.2.json" { |
| 230 | try err("[0.1.2]"); |
| 231 | } |
| 232 | test "n_number_0.3e+.json" { |
| 233 | try err("[0.3e+]"); |
| 234 | } |
| 235 | test "n_number_0.3e.json" { |
| 236 | try err("[0.3e]"); |
| 237 | } |
| 238 | test "n_number_0.e1.json" { |
| 239 | try err("[0.e1]"); |
| 240 | } |
| 241 | test "n_number_0_capital_E+.json" { |
| 242 | try err("[0E+]"); |
| 243 | } |
| 244 | test "n_number_0_capital_E.json" { |
| 245 | try err("[0E]"); |
| 246 | } |
| 247 | test "n_number_0e+.json" { |
| 248 | try err("[0e+]"); |
| 249 | } |
| 250 | test "n_number_0e.json" { |
| 251 | try err("[0e]"); |
| 252 | } |
| 253 | test "n_number_1.0e+.json" { |
| 254 | try err("[1.0e+]"); |
| 255 | } |
| 256 | test "n_number_1.0e-.json" { |
| 257 | try err("[1.0e-]"); |
| 258 | } |
| 259 | test "n_number_1.0e.json" { |
| 260 | try err("[1.0e]"); |
| 261 | } |
| 262 | test "n_number_1_000.json" { |
| 263 | try err("[1 000.0]"); |
| 264 | } |
| 265 | test "n_number_1eE2.json" { |
| 266 | try err("[1eE2]"); |
| 267 | } |
| 268 | test "n_number_2.e+3.json" { |
| 269 | try err("[2.e+3]"); |
| 270 | } |
| 271 | test "n_number_2.e-3.json" { |
| 272 | try err("[2.e-3]"); |
| 273 | } |
| 274 | test "n_number_2.e3.json" { |
| 275 | try err("[2.e3]"); |
| 276 | } |
| 277 | test "n_number_9.e+.json" { |
| 278 | try err("[9.e+]"); |
| 279 | } |
| 280 | test "n_number_Inf.json" { |
| 281 | try err("[Inf]"); |
| 282 | } |
| 283 | test "n_number_NaN.json" { |
| 284 | try err("[NaN]"); |
| 285 | } |
| 286 | test "n_number_U+FF11_fullwidth_digit_one.json" { |
| 287 | try err("[\xef\xbc\x91]"); |
| 288 | } |
| 289 | test "n_number_expression.json" { |
| 290 | try err("[1+2]"); |
| 291 | } |
| 292 | test "n_number_hex_1_digit.json" { |
| 293 | try err("[0x1]"); |
| 294 | } |
| 295 | test "n_number_hex_2_digits.json" { |
| 296 | try err("[0x42]"); |
| 297 | } |
| 298 | test "n_number_infinity.json" { |
| 299 | try err("[Infinity]"); |
| 300 | } |
| 301 | test "n_number_invalid+-.json" { |
| 302 | try err("[0e+-1]"); |
| 303 | } |
| 304 | test "n_number_invalid-negative-real.json" { |
| 305 | try err("[-123.123foo]"); |
| 306 | } |
| 307 | test "n_number_invalid-utf-8-in-bigger-int.json" { |
| 308 | try err("[123\xe5]"); |
| 309 | } |
| 310 | test "n_number_invalid-utf-8-in-exponent.json" { |
| 311 | try err("[1e1\xe5]"); |
| 312 | } |
| 313 | test "n_number_invalid-utf-8-in-int.json" { |
| 314 | try err("[0\xe5]\n"); |
| 315 | } |
| 316 | test "n_number_minus_infinity.json" { |
| 317 | try err("[-Infinity]"); |
| 318 | } |
| 319 | test "n_number_minus_sign_with_trailing_garbage.json" { |
| 320 | try err("[-foo]"); |
| 321 | } |
| 322 | test "n_number_minus_space_1.json" { |
| 323 | try err("[- 1]"); |
| 324 | } |
| 325 | test "n_number_neg_int_starting_with_zero.json" { |
| 326 | try err("[-012]"); |
| 327 | } |
| 328 | test "n_number_neg_real_without_int_part.json" { |
| 329 | try err("[-.123]"); |
| 330 | } |
| 331 | test "n_number_neg_with_garbage_at_end.json" { |
| 332 | try err("[-1x]"); |
| 333 | } |
| 334 | test "n_number_real_garbage_after_e.json" { |
| 335 | try err("[1ea]"); |
| 336 | } |
| 337 | test "n_number_real_with_invalid_utf8_after_e.json" { |
| 338 | try err("[1e\xe5]"); |
| 339 | } |
| 340 | test "n_number_real_without_fractional_part.json" { |
| 341 | try err("[1.]"); |
| 342 | } |
| 343 | test "n_number_starting_with_dot.json" { |
| 344 | try err("[.123]"); |
| 345 | } |
| 346 | test "n_number_with_alpha.json" { |
| 347 | try err("[1.2a-3]"); |
| 348 | } |
| 349 | test "n_number_with_alpha_char.json" { |
| 350 | try err("[1.8011670033376514H-308]"); |
| 351 | } |
| 352 | test "n_number_with_leading_zero.json" { |
| 353 | try err("[012]"); |
| 354 | } |
| 355 | test "n_object_bad_value.json" { |
| 356 | try err("[\"x\", truth]"); |
| 357 | } |
| 358 | test "n_object_bracket_key.json" { |
| 359 | try err("{[: \"x\"}\n"); |
| 360 | } |
| 361 | test "n_object_comma_instead_of_colon.json" { |
| 362 | try err("{\"x\", null}"); |
| 363 | } |
| 364 | test "n_object_double_colon.json" { |
| 365 | try err("{\"x\"::\"b\"}"); |
| 366 | } |
| 367 | test "n_object_emoji.json" { |
| 368 | try err("{\xf0\x9f\x87\xa8\xf0\x9f\x87\xad}"); |
| 369 | } |
| 370 | test "n_object_garbage_at_end.json" { |
| 371 | try err("{\"a\":\"a\" 123}"); |
| 372 | } |
| 373 | test "n_object_key_with_single_quotes.json" { |
| 374 | try err("{key: 'value'}"); |
| 375 | } |
| 376 | test "n_object_lone_continuation_byte_in_key_and_trailing_comma.json" { |
| 377 | try err("{\"\xb9\":\"0\",}"); |
| 378 | } |
| 379 | test "n_object_missing_colon.json" { |
| 380 | try err("{\"a\" b}"); |
| 381 | } |
| 382 | test "n_object_missing_key.json" { |
| 383 | try err("{:\"b\"}"); |
| 384 | } |
| 385 | test "n_object_missing_semicolon.json" { |
| 386 | try err("{\"a\" \"b\"}"); |
| 387 | } |
| 388 | test "n_object_missing_value.json" { |
| 389 | try err("{\"a\":"); |
| 390 | } |
| 391 | test "n_object_no-colon.json" { |
| 392 | try err("{\"a\""); |
| 393 | } |
| 394 | test "n_object_non_string_key.json" { |
| 395 | try err("{1:1}"); |
| 396 | } |
| 397 | test "n_object_non_string_key_but_huge_number_instead.json" { |
| 398 | try err("{9999E9999:1}"); |
| 399 | } |
| 400 | test "n_object_repeated_null_null.json" { |
| 401 | try err("{null:null,null:null}"); |
| 402 | } |
| 403 | test "n_object_several_trailing_commas.json" { |
| 404 | try err("{\"id\":0,,,,,}"); |
| 405 | } |
| 406 | test "n_object_single_quote.json" { |
| 407 | try err("{'a':0}"); |
| 408 | } |
| 409 | test "n_object_trailing_comma.json" { |
| 410 | try err("{\"id\":0,}"); |
| 411 | } |
| 412 | test "n_object_trailing_comment.json" { |
| 413 | try err("{\"a\":\"b\"}/**/"); |
| 414 | } |
| 415 | test "n_object_trailing_comment_open.json" { |
| 416 | try err("{\"a\":\"b\"}/**//"); |
| 417 | } |
| 418 | test "n_object_trailing_comment_slash_open.json" { |
| 419 | try err("{\"a\":\"b\"}//"); |
| 420 | } |
| 421 | test "n_object_trailing_comment_slash_open_incomplete.json" { |
| 422 | try err("{\"a\":\"b\"}/"); |
| 423 | } |
| 424 | test "n_object_two_commas_in_a_row.json" { |
| 425 | try err("{\"a\":\"b\",,\"c\":\"d\"}"); |
| 426 | } |
| 427 | test "n_object_unquoted_key.json" { |
| 428 | try err("{a: \"b\"}"); |
| 429 | } |
| 430 | test "n_object_unterminated-value.json" { |
| 431 | try err("{\"a\":\"a"); |
| 432 | } |
| 433 | test "n_object_with_single_string.json" { |
| 434 | try err("{ \"foo\" : \"bar\", \"a\" }"); |
| 435 | } |
| 436 | test "n_object_with_trailing_garbage.json" { |
| 437 | try err("{\"a\":\"b\"}#"); |
| 438 | } |
| 439 | test "n_single_space.json" { |
| 440 | try err(" "); |
| 441 | } |
| 442 | test "n_string_1_surrogate_then_escape.json" { |
| 443 | try err("[\"\\uD800\\\"]"); |
| 444 | } |
| 445 | test "n_string_1_surrogate_then_escape_u.json" { |
| 446 | try err("[\"\\uD800\\u\"]"); |
| 447 | } |
| 448 | test "n_string_1_surrogate_then_escape_u1.json" { |
| 449 | try err("[\"\\uD800\\u1\"]"); |
| 450 | } |
| 451 | test "n_string_1_surrogate_then_escape_u1x.json" { |
| 452 | try err("[\"\\uD800\\u1x\"]"); |
| 453 | } |
| 454 | test "n_string_accentuated_char_no_quotes.json" { |
| 455 | try err("[\xc3\xa9]"); |
| 456 | } |
| 457 | test "n_string_backslash_00.json" { |
| 458 | try err("[\"\\\x00\"]"); |
| 459 | } |
| 460 | test "n_string_escape_x.json" { |
| 461 | try err("[\"\\x00\"]"); |
| 462 | } |
| 463 | test "n_string_escaped_backslash_bad.json" { |
| 464 | try err("[\"\\\\\\\"]"); |
| 465 | } |
| 466 | test "n_string_escaped_ctrl_char_tab.json" { |
| 467 | try err("[\"\\\x09\"]"); |
| 468 | } |
| 469 | test "n_string_escaped_emoji.json" { |
| 470 | try err("[\"\\\xf0\x9f\x8c\x80\"]"); |
| 471 | } |
| 472 | test "n_string_incomplete_escape.json" { |
| 473 | try err("[\"\\\"]"); |
| 474 | } |
| 475 | test "n_string_incomplete_escaped_character.json" { |
| 476 | try err("[\"\\u00A\"]"); |
| 477 | } |
| 478 | test "n_string_incomplete_surrogate.json" { |
| 479 | try err("[\"\\uD834\\uDd\"]"); |
| 480 | } |
| 481 | test "n_string_incomplete_surrogate_escape_invalid.json" { |
| 482 | try err("[\"\\uD800\\uD800\\x\"]"); |
| 483 | } |
| 484 | test "n_string_invalid-utf-8-in-escape.json" { |
| 485 | try err("[\"\\u\xe5\"]"); |
| 486 | } |
| 487 | test "n_string_invalid_backslash_esc.json" { |
| 488 | try err("[\"\\a\"]"); |
| 489 | } |
| 490 | test "n_string_invalid_unicode_escape.json" { |
| 491 | try err("[\"\\uqqqq\"]"); |
| 492 | } |
| 493 | test "n_string_invalid_utf8_after_escape.json" { |
| 494 | try err("[\"\\\xe5\"]"); |
| 495 | } |
| 496 | test "n_string_leading_uescaped_thinspace.json" { |
| 497 | try err("[\\u0020\"asd\"]"); |
| 498 | } |
| 499 | test "n_string_no_quotes_with_bad_escape.json" { |
| 500 | try err("[\\n]"); |
| 501 | } |
| 502 | test "n_string_single_doublequote.json" { |
| 503 | try err("\""); |
| 504 | } |
| 505 | test "n_string_single_quote.json" { |
| 506 | try err("['single quote']"); |
| 507 | } |
| 508 | test "n_string_single_string_no_double_quotes.json" { |
| 509 | try err("abc"); |
| 510 | } |
| 511 | test "n_string_start_escape_unclosed.json" { |
| 512 | try err("[\"\\"); |
| 513 | } |
| 514 | test "n_string_unescaped_ctrl_char.json" { |
| 515 | try err("[\"a\x00a\"]"); |
| 516 | } |
| 517 | test "n_string_unescaped_newline.json" { |
| 518 | try err("[\"new\nline\"]"); |
| 519 | } |
| 520 | test "n_string_unescaped_tab.json" { |
| 521 | try err("[\"\x09\"]"); |
| 522 | } |
| 523 | test "n_string_unicode_CapitalU.json" { |
| 524 | try err("\"\\UA66D\""); |
| 525 | } |
| 526 | test "n_string_with_trailing_garbage.json" { |
| 527 | try err("\"\"x"); |
| 528 | } |
| 529 | test "n_structure_100000_opening_arrays.json" { |
| 530 | try err(&@as([100000]u8, @splat('['))); |
| 531 | } |
| 532 | test "n_structure_U+2060_word_joined.json" { |
| 533 | try err("[\xe2\x81\xa0]"); |
| 534 | } |
| 535 | test "n_structure_UTF8_BOM_no_data.json" { |
| 536 | try err("\xef\xbb\xbf"); |
| 537 | } |
| 538 | test "n_structure_angle_bracket_..json" { |
| 539 | try err("<.>"); |
| 540 | } |
| 541 | test "n_structure_angle_bracket_null.json" { |
| 542 | try err("[<null>]"); |
| 543 | } |
| 544 | test "n_structure_array_trailing_garbage.json" { |
| 545 | try err("[1]x"); |
| 546 | } |
| 547 | test "n_structure_array_with_extra_array_close.json" { |
| 548 | try err("[1]]"); |
| 549 | } |
| 550 | test "n_structure_array_with_unclosed_string.json" { |
| 551 | try err("[\"asd]"); |
| 552 | } |
| 553 | test "n_structure_ascii-unicode-identifier.json" { |
| 554 | try err("a\xc3\xa5"); |
| 555 | } |
| 556 | test "n_structure_capitalized_True.json" { |
| 557 | try err("[True]"); |
| 558 | } |
| 559 | test "n_structure_close_unopened_array.json" { |
| 560 | try err("1]"); |
| 561 | } |
| 562 | test "n_structure_comma_instead_of_closing_brace.json" { |
| 563 | try err("{\"x\": true,"); |
| 564 | } |
| 565 | test "n_structure_double_array.json" { |
| 566 | try err("[][]"); |
| 567 | } |
| 568 | test "n_structure_end_array.json" { |
| 569 | try err("]"); |
| 570 | } |
| 571 | test "n_structure_incomplete_UTF8_BOM.json" { |
| 572 | try err("\xef\xbb{}"); |
| 573 | } |
| 574 | test "n_structure_lone-invalid-utf-8.json" { |
| 575 | try err("\xe5"); |
| 576 | } |
| 577 | test "n_structure_lone-open-bracket.json" { |
| 578 | try err("["); |
| 579 | } |
| 580 | test "n_structure_no_data.json" { |
| 581 | try err(""); |
| 582 | } |
| 583 | test "n_structure_null-byte-outside-string.json" { |
| 584 | try err("[\x00]"); |
| 585 | } |
| 586 | test "n_structure_number_with_trailing_garbage.json" { |
| 587 | try err("2@"); |
| 588 | } |
| 589 | test "n_structure_object_followed_by_closing_object.json" { |
| 590 | try err("{}}"); |
| 591 | } |
| 592 | test "n_structure_object_unclosed_no_value.json" { |
| 593 | try err("{\"\":"); |
| 594 | } |
| 595 | test "n_structure_object_with_comment.json" { |
| 596 | try err("{\"a\":/*comment*/\"b\"}"); |
| 597 | } |
| 598 | test "n_structure_object_with_trailing_garbage.json" { |
| 599 | try err("{\"a\": true} \"x\""); |
| 600 | } |
| 601 | test "n_structure_open_array_apostrophe.json" { |
| 602 | try err("['"); |
| 603 | } |
| 604 | test "n_structure_open_array_comma.json" { |
| 605 | try err("[,"); |
| 606 | } |
| 607 | test "n_structure_open_array_object.json" { |
| 608 | try err(str: { |
| 609 | const part = "[{\"\":"; |
| 610 | const buf: [50000][part.len]u8 = @splat(part.*); |
| 611 | const s: []const u8 = @ptrCast(&buf); |
| 612 | break :str s ++ "\n"; |
| 613 | }); |
| 614 | } |
| 615 | test "n_structure_open_array_open_object.json" { |
| 616 | try err("[{"); |
| 617 | } |
| 618 | test "n_structure_open_array_open_string.json" { |
| 619 | try err("[\"a"); |
| 620 | } |
| 621 | test "n_structure_open_array_string.json" { |
| 622 | try err("[\"a\""); |
| 623 | } |
| 624 | test "n_structure_open_object.json" { |
| 625 | try err("{"); |
| 626 | } |
| 627 | test "n_structure_open_object_close_array.json" { |
| 628 | try err("{]"); |
| 629 | } |
| 630 | test "n_structure_open_object_comma.json" { |
| 631 | try err("{,"); |
| 632 | } |
| 633 | test "n_structure_open_object_open_array.json" { |
| 634 | try err("{["); |
| 635 | } |
| 636 | test "n_structure_open_object_open_string.json" { |
| 637 | try err("{\"a"); |
| 638 | } |
| 639 | test "n_structure_open_object_string_with_apostrophes.json" { |
| 640 | try err("{'a'"); |
| 641 | } |
| 642 | test "n_structure_open_open.json" { |
| 643 | try err("[\"\\{[\"\\{[\"\\{[\"\\{"); |
| 644 | } |
| 645 | test "n_structure_single_eacute.json" { |
| 646 | try err("\xe9"); |
| 647 | } |
| 648 | test "n_structure_single_star.json" { |
| 649 | try err("*"); |
| 650 | } |
| 651 | test "n_structure_trailing_#.json" { |
| 652 | try err("{\"a\":\"b\"}#{}"); |
| 653 | } |
| 654 | test "n_structure_uescaped_LF_before_string.json" { |
| 655 | try err("[\\u000A\"\"]"); |
| 656 | } |
| 657 | test "n_structure_unclosed_array.json" { |
| 658 | try err("[1"); |
| 659 | } |
| 660 | test "n_structure_unclosed_array_partial_null.json" { |
| 661 | try err("[ false, nul"); |
| 662 | } |
| 663 | test "n_structure_unclosed_array_unfinished_false.json" { |
| 664 | try err("[ true, fals"); |
| 665 | } |
| 666 | test "n_structure_unclosed_array_unfinished_true.json" { |
| 667 | try err("[ false, tru"); |
| 668 | } |
| 669 | test "n_structure_unclosed_object.json" { |
| 670 | try err("{\"asd\":\"asd\""); |
| 671 | } |
| 672 | test "n_structure_unicode-identifier.json" { |
| 673 | try err("\xc3\xa5"); |
| 674 | } |
| 675 | test "n_structure_whitespace_U+2060_word_joiner.json" { |
| 676 | try err("[\xe2\x81\xa0]"); |
| 677 | } |
| 678 | test "n_structure_whitespace_formfeed.json" { |
| 679 | try err("[\x0c]"); |
| 680 | } |
| 681 | test "y_array_arraysWithSpaces.json" { |
| 682 | try ok("[[] ]"); |
| 683 | } |
| 684 | test "y_array_empty-string.json" { |
| 685 | try ok("[\"\"]"); |
| 686 | } |
| 687 | test "y_array_empty.json" { |
| 688 | try ok("[]"); |
| 689 | } |
| 690 | test "y_array_ending_with_newline.json" { |
| 691 | try ok("[\"a\"]"); |
| 692 | } |
| 693 | test "y_array_false.json" { |
| 694 | try ok("[false]"); |
| 695 | } |
| 696 | test "y_array_heterogeneous.json" { |
| 697 | try ok("[null, 1, \"1\", {}]"); |
| 698 | } |
| 699 | test "y_array_null.json" { |
| 700 | try ok("[null]"); |
| 701 | } |
| 702 | test "y_array_with_1_and_newline.json" { |
| 703 | try ok("[1\n]"); |
| 704 | } |
| 705 | test "y_array_with_leading_space.json" { |
| 706 | try ok(" [1]"); |
| 707 | } |
| 708 | test "y_array_with_several_null.json" { |
| 709 | try ok("[1,null,null,null,2]"); |
| 710 | } |
| 711 | test "y_array_with_trailing_space.json" { |
| 712 | try ok("[2] "); |
| 713 | } |
| 714 | test "y_number.json" { |
| 715 | try ok("[123e65]"); |
| 716 | } |
| 717 | test "y_number_0e+1.json" { |
| 718 | try ok("[0e+1]"); |
| 719 | } |
| 720 | test "y_number_0e1.json" { |
| 721 | try ok("[0e1]"); |
| 722 | } |
| 723 | test "y_number_after_space.json" { |
| 724 | try ok("[ 4]"); |
| 725 | } |
| 726 | test "y_number_double_close_to_zero.json" { |
| 727 | try ok("[-0.000000000000000000000000000000000000000000000000000000000000000000000000000001]\n"); |
| 728 | } |
| 729 | test "y_number_int_with_exp.json" { |
| 730 | try ok("[20e1]"); |
| 731 | } |
| 732 | test "y_number_minus_zero.json" { |
| 733 | try ok("[-0]"); |
| 734 | } |
| 735 | test "y_number_negative_int.json" { |
| 736 | try ok("[-123]"); |
| 737 | } |
| 738 | test "y_number_negative_one.json" { |
| 739 | try ok("[-1]"); |
| 740 | } |
| 741 | test "y_number_negative_zero.json" { |
| 742 | try ok("[-0]"); |
| 743 | } |
| 744 | test "y_number_real_capital_e.json" { |
| 745 | try ok("[1E22]"); |
| 746 | } |
| 747 | test "y_number_real_capital_e_neg_exp.json" { |
| 748 | try ok("[1E-2]"); |
| 749 | } |
| 750 | test "y_number_real_capital_e_pos_exp.json" { |
| 751 | try ok("[1E+2]"); |
| 752 | } |
| 753 | test "y_number_real_exponent.json" { |
| 754 | try ok("[123e45]"); |
| 755 | } |
| 756 | test "y_number_real_fraction_exponent.json" { |
| 757 | try ok("[123.456e78]"); |
| 758 | } |
| 759 | test "y_number_real_neg_exp.json" { |
| 760 | try ok("[1e-2]"); |
| 761 | } |
| 762 | test "y_number_real_pos_exponent.json" { |
| 763 | try ok("[1e+2]"); |
| 764 | } |
| 765 | test "y_number_simple_int.json" { |
| 766 | try ok("[123]"); |
| 767 | } |
| 768 | test "y_number_simple_real.json" { |
| 769 | try ok("[123.456789]"); |
| 770 | } |
| 771 | test "y_object.json" { |
| 772 | try ok("{\"asd\":\"sdf\", \"dfg\":\"fgh\"}"); |
| 773 | } |
| 774 | test "y_object_basic.json" { |
| 775 | try ok("{\"asd\":\"sdf\"}"); |
| 776 | } |
| 777 | test "y_object_duplicated_key.json" { |
| 778 | try ok("{\"a\":\"b\",\"a\":\"c\"}"); |
| 779 | } |
| 780 | test "y_object_duplicated_key_and_value.json" { |
| 781 | try ok("{\"a\":\"b\",\"a\":\"b\"}"); |
| 782 | } |
| 783 | test "y_object_empty.json" { |
| 784 | try ok("{}"); |
| 785 | } |
| 786 | test "y_object_empty_key.json" { |
| 787 | try ok("{\"\":0}"); |
| 788 | } |
| 789 | test "y_object_escaped_null_in_key.json" { |
| 790 | try ok("{\"foo\\u0000bar\": 42}"); |
| 791 | } |
| 792 | test "y_object_extreme_numbers.json" { |
| 793 | try ok("{ \"min\": -1.0e+28, \"max\": 1.0e+28 }"); |
| 794 | } |
| 795 | test "y_object_long_strings.json" { |
| 796 | try ok("{\"x\":[{\"id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}], \"id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}"); |
| 797 | } |
| 798 | test "y_object_simple.json" { |
| 799 | try ok("{\"a\":[]}"); |
| 800 | } |
| 801 | test "y_object_string_unicode.json" { |
| 802 | try ok("{\"title\":\"\\u041f\\u043e\\u043b\\u0442\\u043e\\u0440\\u0430 \\u0417\\u0435\\u043c\\u043b\\u0435\\u043a\\u043e\\u043f\\u0430\" }"); |
| 803 | } |
| 804 | test "y_object_with_newlines.json" { |
| 805 | try ok("{\n\"a\": \"b\"\n}"); |
| 806 | } |
| 807 | test "y_string_1_2_3_bytes_UTF-8_sequences.json" { |
| 808 | try ok("[\"\\u0060\\u012a\\u12AB\"]"); |
| 809 | } |
| 810 | test "y_string_accepted_surrogate_pair.json" { |
| 811 | try ok("[\"\\uD801\\udc37\"]"); |
| 812 | } |
| 813 | test "y_string_accepted_surrogate_pairs.json" { |
| 814 | try ok("[\"\\ud83d\\ude39\\ud83d\\udc8d\"]"); |
| 815 | } |
| 816 | test "y_string_allowed_escapes.json" { |
| 817 | try ok("[\"\\\"\\\\\\/\\b\\f\\n\\r\\t\"]"); |
| 818 | } |
| 819 | test "y_string_backslash_and_u_escaped_zero.json" { |
| 820 | try ok("[\"\\\\u0000\"]"); |
| 821 | } |
| 822 | test "y_string_backslash_doublequotes.json" { |
| 823 | try ok("[\"\\\"\"]"); |
| 824 | } |
| 825 | test "y_string_comments.json" { |
| 826 | try ok("[\"a/*b*/c/*d//e\"]"); |
| 827 | } |
| 828 | test "y_string_double_escape_a.json" { |
| 829 | try ok("[\"\\\\a\"]"); |
| 830 | } |
| 831 | test "y_string_double_escape_n.json" { |
| 832 | try ok("[\"\\\\n\"]"); |
| 833 | } |
| 834 | test "y_string_escaped_control_character.json" { |
| 835 | try ok("[\"\\u0012\"]"); |
| 836 | } |
| 837 | test "y_string_escaped_noncharacter.json" { |
| 838 | try ok("[\"\\uFFFF\"]"); |
| 839 | } |
| 840 | test "y_string_in_array.json" { |
| 841 | try ok("[\"asd\"]"); |
| 842 | } |
| 843 | test "y_string_in_array_with_leading_space.json" { |
| 844 | try ok("[ \"asd\"]"); |
| 845 | } |
| 846 | test "y_string_last_surrogates_1_and_2.json" { |
| 847 | try ok("[\"\\uDBFF\\uDFFF\"]"); |
| 848 | } |
| 849 | test "y_string_nbsp_uescaped.json" { |
| 850 | try ok("[\"new\\u00A0line\"]"); |
| 851 | } |
| 852 | test "y_string_nonCharacterInUTF-8_U+10FFFF.json" { |
| 853 | try ok("[\"\xf4\x8f\xbf\xbf\"]"); |
| 854 | } |
| 855 | test "y_string_nonCharacterInUTF-8_U+FFFF.json" { |
| 856 | try ok("[\"\xef\xbf\xbf\"]"); |
| 857 | } |
| 858 | test "y_string_null_escape.json" { |
| 859 | try ok("[\"\\u0000\"]"); |
| 860 | } |
| 861 | test "y_string_one-byte-utf-8.json" { |
| 862 | try ok("[\"\\u002c\"]"); |
| 863 | } |
| 864 | test "y_string_pi.json" { |
| 865 | try ok("[\"\xcf\x80\"]"); |
| 866 | } |
| 867 | test "y_string_reservedCharacterInUTF-8_U+1BFFF.json" { |
| 868 | try ok("[\"\xf0\x9b\xbf\xbf\"]"); |
| 869 | } |
| 870 | test "y_string_simple_ascii.json" { |
| 871 | try ok("[\"asd \"]"); |
| 872 | } |
| 873 | test "y_string_space.json" { |
| 874 | try ok("\" \""); |
| 875 | } |
| 876 | test "y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json" { |
| 877 | try ok("[\"\\uD834\\uDd1e\"]"); |
| 878 | } |
| 879 | test "y_string_three-byte-utf-8.json" { |
| 880 | try ok("[\"\\u0821\"]"); |
| 881 | } |
| 882 | test "y_string_two-byte-utf-8.json" { |
| 883 | try ok("[\"\\u0123\"]"); |
| 884 | } |
| 885 | test "y_string_u+2028_line_sep.json" { |
| 886 | try ok("[\"\xe2\x80\xa8\"]"); |
| 887 | } |
| 888 | test "y_string_u+2029_par_sep.json" { |
| 889 | try ok("[\"\xe2\x80\xa9\"]"); |
| 890 | } |
| 891 | test "y_string_uEscape.json" { |
| 892 | try ok("[\"\\u0061\\u30af\\u30EA\\u30b9\"]"); |
| 893 | } |
| 894 | test "y_string_uescaped_newline.json" { |
| 895 | try ok("[\"new\\u000Aline\"]"); |
| 896 | } |
| 897 | test "y_string_unescaped_char_delete.json" { |
| 898 | try ok("[\"\x7f\"]"); |
| 899 | } |
| 900 | test "y_string_unicode.json" { |
| 901 | try ok("[\"\\uA66D\"]"); |
| 902 | } |
| 903 | test "y_string_unicodeEscapedBackslash.json" { |
| 904 | try ok("[\"\\u005C\"]"); |
| 905 | } |
| 906 | test "y_string_unicode_2.json" { |
| 907 | try ok("[\"\xe2\x8d\x82\xe3\x88\xb4\xe2\x8d\x82\"]"); |
| 908 | } |
| 909 | test "y_string_unicode_U+10FFFE_nonchar.json" { |
| 910 | try ok("[\"\\uDBFF\\uDFFE\"]"); |
| 911 | } |
| 912 | test "y_string_unicode_U+1FFFE_nonchar.json" { |
| 913 | try ok("[\"\\uD83F\\uDFFE\"]"); |
| 914 | } |
| 915 | test "y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json" { |
| 916 | try ok("[\"\\u200B\"]"); |
| 917 | } |
| 918 | test "y_string_unicode_U+2064_invisible_plus.json" { |
| 919 | try ok("[\"\\u2064\"]"); |
| 920 | } |
| 921 | test "y_string_unicode_U+FDD0_nonchar.json" { |
| 922 | try ok("[\"\\uFDD0\"]"); |
| 923 | } |
| 924 | test "y_string_unicode_U+FFFE_nonchar.json" { |
| 925 | try ok("[\"\\uFFFE\"]"); |
| 926 | } |
| 927 | test "y_string_unicode_escaped_double_quote.json" { |
| 928 | try ok("[\"\\u0022\"]"); |
| 929 | } |
| 930 | test "y_string_utf8.json" { |
| 931 | try ok("[\"\xe2\x82\xac\xf0\x9d\x84\x9e\"]"); |
| 932 | } |
| 933 | test "y_string_with_del_character.json" { |
| 934 | try ok("[\"a\x7fa\"]"); |
| 935 | } |
| 936 | test "y_structure_lonely_false.json" { |
| 937 | try ok("false"); |
| 938 | } |
| 939 | test "y_structure_lonely_int.json" { |
| 940 | try ok("42"); |
| 941 | } |
| 942 | test "y_structure_lonely_negative_real.json" { |
| 943 | try ok("-0.1"); |
| 944 | } |
| 945 | test "y_structure_lonely_null.json" { |
| 946 | try ok("null"); |
| 947 | } |
| 948 | test "y_structure_lonely_string.json" { |
| 949 | try ok("\"asd\""); |
| 950 | } |
| 951 | test "y_structure_lonely_true.json" { |
| 952 | try ok("true"); |
| 953 | } |
| 954 | test "y_structure_string_empty.json" { |
| 955 | try ok("\"\""); |
| 956 | } |
| 957 | test "y_structure_trailing_newline.json" { |
| 958 | try ok("[\"a\"]\n"); |
| 959 | } |
| 960 | test "y_structure_true_in_array.json" { |
| 961 | try ok("[true]"); |
| 962 | } |
| 963 | test "y_structure_whitespace_array.json" { |
| 964 | try ok(" [] "); |
| 965 | } |