From 4c116841840bfa7f0068bef23984dd832da8a54d Mon Sep 17 00:00:00 2001 From: Jon-Eric Cook Date: Sat, 28 Jan 2023 08:26:36 -0800 Subject: std.json: check output and source lengths in `std.json` --- lib/std/json/test.zig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/std/json') diff --git a/lib/std/json/test.zig b/lib/std/json/test.zig index 2a590fdf15..0bf0797587 100644 --- a/lib/std/json/test.zig +++ b/lib/std/json/test.zig @@ -2238,6 +2238,12 @@ test "parse into struct with no fields" { try testing.expectEqual(T{}, try parse(T, &ts, ParseOptions{})); } +test "parse into struct where destination and source lengths mismatch" { + const T = struct { a: [2]u8 }; + var ts = TokenStream.init("{\"a\": \"bbb\"}"); + try testing.expectError(error.LengthMismatch, parse(T, &ts, ParseOptions{})); +} + test "parse into struct with misc fields" { @setEvalBranchQuota(10000); const options = ParseOptions{ .allocator = testing.allocator }; -- cgit v1.2.3