From c7a314e20a7e0d55cf431f35defd82738f07dfc9 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Sat, 29 Oct 2022 14:17:35 -0700 Subject: [PATCH] tests: add decompress() tests for multiple frames and extra data Related to #59 and #181. The existing behavior isn't great. But we should at least have tests to keep us honest if/when behavior changes. --- tests/test_decompressor_decompress.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_decompressor_decompress.py b/tests/test_decompressor_decompress.py index f6c7af7f..d3e8d0e9 100644 --- a/tests/test_decompressor_decompress.py +++ b/tests/test_decompressor_decompress.py @@ -175,3 +175,18 @@ def test_explicit_default_params(self): format=zstd.FORMAT_ZSTD1, ) self.assertEqual(dctx.decompress(compressed), b"foo") + + def test_multiple_frames(self): + cctx = zstd.ZstdCompressor() + foo = cctx.compress(b"foo") + bar = cctx.compress(b"bar") + + dctx = zstd.ZstdDecompressor() + self.assertEqual(dctx.decompress(foo + bar), b"foo") + + def test_junk_after_frame(self): + cctx = zstd.ZstdCompressor() + frame = cctx.compress(b"foo") + + dctx = zstd.ZstdDecompressor() + self.assertEqual(dctx.decompress(frame + b"junk"), b"foo")