Add tests for jebp_utils

This commit is contained in:
2026-04-02 12:34:21 +02:00
parent b12555d883
commit 32ed782fef
5 changed files with 119 additions and 4 deletions
+20
View File
@@ -0,0 +1,20 @@
from src.jeb_utils.jebp_utils import pack_fields
import pytest
@pytest.mark.parametrize('fields,expected', [
([], b''),
([b''], b'\x01\x00'),
([b'', b''], b'\x01\x00\x01\x00'),
([b'', b'a'], b'\x01\x00\x01\x01a'),
([b'', b'ab'], b'\x01\x00\x01\x02ab'),
([b'a', b'ab'], b'\x01\x01a\x01\x02ab'),
([b'a', b'ab', b'', b'Hello, World!'], b'\x01\x01a\x01\x02ab\x01\x00\x01\x0dHello, World!'),
([b'a' * 255], b'\x01\xff' + b'a' * 255),
([b'a' * 255, b'a' * 255], (b'\x01\xff' + b'a' * 255) * 2),
([b'a' * 256], b'\x02\x01\x00' + b'a' * 256),
([b'a' * 256, b'a' * 256], (b'\x02\x01\x00' + b'a' * 256) * 2),
([b'a' * 257], b'\x02\x01\x01' + b'a' * 257),
([b'a' * 257, b'abc'], b'\x02\x01\x01' + b'a' * 257 + b'\x01\x03abc'),
])
def test_pack_fields(fields, expected):
assert pack_fields(fields) == expected