Skip to content

Commit 56cb7f1

Browse files
committed
update json_test to be compliant with zig source encoding
See #663
1 parent 3f302f8 commit 56cb7f1

File tree

1 file changed

+15
-45
lines changed

1 file changed

+15
-45
lines changed

std/json_test.zig

+15-45
Original file line numberDiff line numberDiff line change
@@ -431,15 +431,11 @@ test "y_string_two-byte-utf-8" {
431431
}
432432

433433
test "y_string_u+2028_line_sep" {
434-
ok(
435-
\\["
"]
436-
);
434+
ok("[\"\xe2\x80\xa8\"]");
437435
}
438436

439437
test "y_string_u+2029_par_sep" {
440-
ok(
441-
\\["
"]
442-
);
438+
ok("[\"\xe2\x80\xa9\"]");
443439
}
444440

445441
test "y_string_uescaped_newline" {
@@ -455,9 +451,7 @@ test "y_string_uEscape" {
455451
}
456452

457453
test "y_string_unescaped_char_delete" {
458-
ok(
459-
\\[""]
460-
);
454+
ok("[\"\x7f\"]");
461455
}
462456

463457
test "y_string_unicode_2" {
@@ -527,9 +521,7 @@ test "y_string_utf8" {
527521
}
528522

529523
test "y_string_with_del_character" {
530-
ok(
531-
\\["aa"]
532-
);
524+
ok("[\"a\x7fa\"]");
533525
}
534526

535527
test "y_structure_lonely_false" {
@@ -718,9 +710,7 @@ test "n_array_number_and_several_commas" {
718710
}
719711

720712
test "n_array_spaces_vertical_tab_formfeed" {
721-
err(
722-
\\[" a"\f]
723-
);
713+
err("[\"\x0aa\"\\f]");
724714
}
725715

726716
test "n_array_star_inside" {
@@ -774,9 +764,7 @@ test "n_incomplete_true" {
774764
}
775765

776766
test "n_multidigit_number_then_00" {
777-
err(
778-
\\123
779-
);
767+
err("123\x00");
780768
}
781769

782770
test "n_number_0.1.2" {
@@ -1309,9 +1297,7 @@ test "n_string_escaped_ctrl_char_tab" {
13091297
}
13101298

13111299
test "n_string_escaped_emoji" {
1312-
err(
1313-
\\["\🌀"]
1314-
);
1300+
err("[\"\x5c\xc3\xb0\xc2\x9f\xc2\x8c\xc2\x80\"]");
13151301
}
13161302

13171303
test "n_string_escape_x" {
@@ -1357,9 +1343,7 @@ test "n_string_invalid_unicode_escape" {
13571343
}
13581344

13591345
test "n_string_invalid_utf8_after_escape" {
1360-
err(
1361-
\\["\å"]
1362-
);
1346+
err("[\"\\\x75\xc3\xa5\"]");
13631347
}
13641348

13651349
test "n_string_invalid-utf-8-in-escape" {
@@ -1405,9 +1389,7 @@ test "n_string_start_escape_unclosed" {
14051389
}
14061390

14071391
test "n_string_unescaped_crtl_char" {
1408-
err(
1409-
\\["aa"]
1410-
);
1392+
err("[\"a\x00a\"]");
14111393
}
14121394

14131395
test "n_string_unescaped_newline" {
@@ -1418,9 +1400,7 @@ test "n_string_unescaped_newline" {
14181400
}
14191401

14201402
test "n_string_unescaped_tab" {
1421-
err(
1422-
\\[" "]
1423-
);
1403+
err("[\"\t\"]");
14241404
}
14251405

14261406
test "n_string_unicode_CapitalU" {
@@ -1532,9 +1512,7 @@ test "n_structure_no_data" {
15321512
}
15331513

15341514
test "n_structure_null-byte-outside-string" {
1535-
err(
1536-
\\[]
1537-
);
1515+
err("[\x00]");
15381516
}
15391517

15401518
test "n_structure_number_with_trailing_garbage" {
@@ -1718,9 +1696,7 @@ test "n_structure_UTF8_BOM_no_data" {
17181696
}
17191697

17201698
test "n_structure_whitespace_formfeed" {
1721-
err(
1722-
\\[ ]
1723-
);
1699+
err("[\x0c]");
17241700
}
17251701

17261702
test "n_structure_whitespace_U+2060_word_joiner" {
@@ -1900,21 +1876,15 @@ test "i_string_truncated-utf-8" {
19001876
}
19011877

19021878
test "i_string_utf16BE_no_BOM" {
1903-
any(
1904-
\\["é"]
1905-
);
1879+
any("\x00\x5b\x00\x22\x00\xc3\xa9\x00\x22\x00\x5d");
19061880
}
19071881

19081882
test "i_string_utf16LE_no_BOM" {
1909-
any(
1910-
\\["é"]
1911-
);
1883+
any("\x5b\x00\x22\x00\xc3\xa9\x00\x22\x00\x5d\x00");
19121884
}
19131885

19141886
test "i_string_UTF-16LE_with_BOM" {
1915-
any(
1916-
\\ÿþ["é"]
1917-
);
1887+
any("\xc3\xbf\xc3\xbe\x5b\x00\x22\x00\xc3\xa9\x00\x22\x00\x5d\x00");
19181888
}
19191889

19201890
test "i_string_UTF-8_invalid_sequence" {

0 commit comments

Comments
 (0)