Skip to content

Commit

Permalink
tests: add decompress() tests for multiple frames and extra data
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
indygreg committed Oct 29, 2022
1 parent e86740d commit c7a314e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_decompressor_decompress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit c7a314e

Please sign in to comment.