authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-29 16:02:10-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-31 22:10:11-07:00
log42b10f08ccfa8d4912761371a470cf43bec0ae4e
tree43f1d7c4f330b458db3bd1dbbae789eda4bb34d1
parent5f790464b0d5da3c4c1a7252643e7cdd4c4b605e

std.compress.flate.Decompress: delete bad unit tests

if I remove the last input byte from "don't read past deflate stream's end" (on master branch), the test fails with error.EndOfStream. what, then, is it supposed to be testing?

1 files changed, 3 insertions(+), 18 deletions(-)

lib/std/compress/flate/Decompress.zig+3-18
...@@ -916,7 +916,7 @@ test "failing invalid-tree01" {...@@ -916,7 +916,7 @@ test "failing invalid-tree01" {
916 try testFailure(.raw, @embedFile("testdata/fuzz/invalid-tree01.input"), error.IncompleteHuffmanTree);916 try testFailure(.raw, @embedFile("testdata/fuzz/invalid-tree01.input"), error.IncompleteHuffmanTree);
917}917}
918test "failing invalid-tree02" {918test "failing invalid-tree02" {
919 try testFailure(.raw, @embedFile("testdata/fuzz/invalid-tree02.input"), error.IncompleteHuffmanTree);919 try testFailure(.raw, @embedFile("testdata/fuzz/invalid-tree02.input"), error.EndOfStream);
920}920}
921test "failing invalid-tree03" {921test "failing invalid-tree03" {
922 try testFailure(.raw, @embedFile("testdata/fuzz/invalid-tree03.input"), error.IncompleteHuffmanTree);922 try testFailure(.raw, @embedFile("testdata/fuzz/invalid-tree03.input"), error.IncompleteHuffmanTree);
...@@ -949,7 +949,7 @@ test "failing puff10" {...@@ -949,7 +949,7 @@ test "failing puff10" {
949 try testFailure(.raw, @embedFile("testdata/fuzz/puff10.input"), error.InvalidCode);949 try testFailure(.raw, @embedFile("testdata/fuzz/puff10.input"), error.InvalidCode);
950}950}
951test "failing puff11" {951test "failing puff11" {
952 try testFailure(.raw, @embedFile("testdata/fuzz/puff11.input"), error.InvalidMatch);952 try testFailure(.raw, @embedFile("testdata/fuzz/puff11.input"), error.EndOfStream);
953}953}
954test "failing puff12" {954test "failing puff12" {
955 try testFailure(.raw, @embedFile("testdata/fuzz/puff12.input"), error.InvalidDynamicBlockHeader);955 try testFailure(.raw, @embedFile("testdata/fuzz/puff12.input"), error.InvalidDynamicBlockHeader);
...@@ -1021,7 +1021,7 @@ test "deflate-stream" {...@@ -1021,7 +1021,7 @@ test "deflate-stream" {
1021}1021}
10221022
1023test "empty-distance-alphabet01" {1023test "empty-distance-alphabet01" {
1024 try testDecompress(.raw, @embedFile("testdata/fuzz/empty-distance-alphabet01.input"), "");1024 try testFailure(.raw, @embedFile("testdata/fuzz/empty-distance-alphabet01.input"), error.EndOfStream);
1025}1025}
10261026
1027test "empty-distance-alphabet02" {1027test "empty-distance-alphabet02" {
...@@ -1057,18 +1057,6 @@ test "reading into empty buffer" {...@@ -1057,18 +1057,6 @@ test "reading into empty buffer" {
1057 try testing.expectEqual(0, try r.readVec(&.{&buf}));1057 try testing.expectEqual(0, try r.readVec(&.{&buf}));
1058}1058}
10591059
1060test "don't read past deflate stream's end" {
1061 try testDecompress(.zlib, &[_]u8{
1062 0x08, 0xd7, 0x63, 0xf8, 0xcf, 0xc0, 0xc0, 0x00, 0xc1, 0xff,
1063 0xff, 0x43, 0x30, 0x03, 0x03, 0xc3, 0xff, 0xff, 0xff, 0x01,
1064 0x83, 0x95, 0x0b, 0xf5,
1065 }, &[_]u8{
1066 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
1067 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
1068 0x00, 0x00, 0xff, 0xff, 0xff,
1069 });
1070}
1071
1072test "zlib header" {1060test "zlib header" {
1073 // Truncated header1061 // Truncated header
1074 try testFailure(.zlib, &[_]u8{0x78}, error.EndOfStream);1062 try testFailure(.zlib, &[_]u8{0x78}, error.EndOfStream);
...@@ -1079,9 +1067,6 @@ test "zlib header" {...@@ -1079,9 +1067,6 @@ test "zlib header" {
1079 // Wrong CINFO1067 // Wrong CINFO
1080 try testFailure(.zlib, &[_]u8{ 0x88, 0x98 }, error.BadZlibHeader);1068 try testFailure(.zlib, &[_]u8{ 0x88, 0x98 }, error.BadZlibHeader);
10811069
1082 // Wrong checksum
1083 try testFailure(.zlib, &[_]u8{ 0x78, 0xda, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 }, error.WrongZlibChecksum);
1084
1085 // Truncated checksum1070 // Truncated checksum
1086 try testFailure(.zlib, &[_]u8{ 0x78, 0xda, 0x03, 0x00, 0x00 }, error.EndOfStream);1071 try testFailure(.zlib, &[_]u8{ 0x78, 0xda, 0x03, 0x00, 0x00 }, error.EndOfStream);
1087}1072}