mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
Stricter tests for non-streaming parser
This commit is contained in:
parent
f9b7d6d75d
commit
6d3b95a708
@ -37,6 +37,18 @@ fn any(comptime s: []const u8) void {
|
||||
_ = p.parse(s) catch {};
|
||||
}
|
||||
|
||||
fn anyStreamingErrNonStreaming(comptime s: []const u8) void {
|
||||
_ = std.json.validate(s);
|
||||
|
||||
var mem_buffer: [1024 * 20]u8 = undefined;
|
||||
const allocator = &std.heap.FixedBufferAllocator.init(&mem_buffer).allocator;
|
||||
var p = std.json.Parser.init(allocator, false);
|
||||
|
||||
if(p.parse(s)) |_| {
|
||||
unreachable;
|
||||
} else |_| {}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Additional tests not part of test JSONTestSuite.
|
||||
@ -1784,49 +1796,49 @@ test "i_number_very_big_negative_int" {
|
||||
}
|
||||
|
||||
test "i_object_key_lone_2nd_surrogate" {
|
||||
any(
|
||||
anyStreamingErrNonStreaming(
|
||||
\\{"\uDFAA":0}
|
||||
);
|
||||
}
|
||||
|
||||
test "i_string_1st_surrogate_but_2nd_missing" {
|
||||
any(
|
||||
anyStreamingErrNonStreaming(
|
||||
\\["\uDADA"]
|
||||
);
|
||||
}
|
||||
|
||||
test "i_string_1st_valid_surrogate_2nd_invalid" {
|
||||
any(
|
||||
anyStreamingErrNonStreaming(
|
||||
\\["\uD888\u1234"]
|
||||
);
|
||||
}
|
||||
|
||||
test "i_string_incomplete_surrogate_and_escape_valid" {
|
||||
any(
|
||||
anyStreamingErrNonStreaming(
|
||||
\\["\uD800\n"]
|
||||
);
|
||||
}
|
||||
|
||||
test "i_string_incomplete_surrogate_pair" {
|
||||
any(
|
||||
anyStreamingErrNonStreaming(
|
||||
\\["\uDd1ea"]
|
||||
);
|
||||
}
|
||||
|
||||
test "i_string_incomplete_surrogates_escape_valid" {
|
||||
any(
|
||||
anyStreamingErrNonStreaming(
|
||||
\\["\uD800\uD800\n"]
|
||||
);
|
||||
}
|
||||
|
||||
test "i_string_invalid_lonely_surrogate" {
|
||||
any(
|
||||
anyStreamingErrNonStreaming(
|
||||
\\["\ud800"]
|
||||
);
|
||||
}
|
||||
|
||||
test "i_string_invalid_surrogate" {
|
||||
any(
|
||||
anyStreamingErrNonStreaming(
|
||||
\\["\ud800abc"]
|
||||
);
|
||||
}
|
||||
@ -1838,7 +1850,7 @@ test "i_string_invalid_utf-8" {
|
||||
}
|
||||
|
||||
test "i_string_inverted_surrogates_U+1D11E" {
|
||||
any(
|
||||
anyStreamingErrNonStreaming(
|
||||
\\["\uDd1e\uD834"]
|
||||
);
|
||||
}
|
||||
@ -1850,7 +1862,7 @@ test "i_string_iso_latin_1" {
|
||||
}
|
||||
|
||||
test "i_string_lone_second_surrogate" {
|
||||
any(
|
||||
anyStreamingErrNonStreaming(
|
||||
\\["\uDFAA"]
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user