Add tests for jebp_utils
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
from src.jeb_utils.jebp_utils import unpack_fields
|
||||
import pytest
|
||||
|
||||
@pytest.mark.parametrize('packed,expected', [
|
||||
(b'', []),
|
||||
(b'\x02\x00\x00', [b'']),
|
||||
(b'\x01\x00', [b'']),
|
||||
(b'\x01\x00\x01\x00', [b'', b'']),
|
||||
(b'\x01\x00\x01\x01a', [b'', b'a']),
|
||||
(b'\x01\x00\x01\x02ab', [b'', b'ab']),
|
||||
(b'\x01\x01a\x01\x02ab', [b'a', b'ab']),
|
||||
(b'\x01\x01a\x01\x02ab\x01\x00\x01\x0dHello, World!', [b'a', b'ab', b'', b'Hello, World!']),
|
||||
(b'\x01\xff' + b'a' * 255, [b'a' * 255]),
|
||||
((b'\x01\xff' + b'a' * 255) * 2, [b'a' * 255, b'a' * 255]),
|
||||
(b'\x02\x01\x00' + b'a' * 256, [b'a' * 256]),
|
||||
((b'\x02\x01\x00' + b'a' * 256) * 2, [b'a' * 256, b'a' * 256]),
|
||||
(b'\x02\x01\x01' + b'a' * 257, [b'a' * 257]),
|
||||
(b'\x02\x01\x01' + b'a' * 257 + b'\x01\x03abc', [b'a' * 257, b'abc']),
|
||||
])
|
||||
def test_unpack_fields(packed, expected):
|
||||
assert unpack_fields(packed) == expected
|
||||
Reference in New Issue
Block a user