mirror of
https://github.com/encounter/lzokay-rs.git
synced 2025-12-13 15:16:09 +00:00
Add python bindings using maturin (#3)
Co-authored-by: Luke Street <luke@street.dev>
This commit is contained in:
committed by
GitHub
parent
c762f2522d
commit
fe436d4386
40
python/tests/test_native.py
Normal file
40
python/tests/test_native.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import pytest
|
||||
|
||||
import lzokay
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"data",
|
||||
[
|
||||
b"Hello World",
|
||||
(
|
||||
b"Hello Worldello Worldello Worldello Worldello Worldello Worldello Worldello "
|
||||
b"Worldello Worldello Worldello Worldello Worldello Worldello Worldello World"
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_compress_and_decompress(data):
|
||||
compressed = lzokay.compress(data)
|
||||
|
||||
decompressed = lzokay.decompress(compressed, len(data))
|
||||
|
||||
assert decompressed == data
|
||||
|
||||
|
||||
def test_output_overrun_decompress():
|
||||
compressed = lzokay.compress(b"Hello World")
|
||||
|
||||
with pytest.raises(lzokay.OutputOverrunError):
|
||||
lzokay.decompress(compressed, 1)
|
||||
|
||||
|
||||
def test_input_overrun_decompress():
|
||||
with pytest.raises(lzokay.InputOverrunError):
|
||||
lzokay.decompress(b"", 1)
|
||||
|
||||
|
||||
def test_input_not_consumed_decompress():
|
||||
compressed = lzokay.compress(b"Hello World")
|
||||
|
||||
with pytest.raises(lzokay.InputNotConsumedError):
|
||||
lzokay.decompress(compressed + b"00000000000", len(compressed))
|
||||
Reference in New Issue
Block a user