eaapi/tests/test_misc.py
2022-02-03 20:55:07 +00:00

42 lines
927 B
Python

import unittest
from eaapi.misc import pack, unpack
class TestPackUnpack(unittest.TestCase):
def test_pack_2(self):
self.assertEqual(
pack(b"\0\1\2\3\3\2\1\0", 2),
b"\x1b\xe4"
)
def test_pack_4(self):
self.assertEqual(
pack(b"\0\1\2\3\4\5\6\7", 4),
b"\x01\x23\x45\x67"
)
def test_pack_5(self):
self.assertEqual(
pack(b"\0\1\2\3\4\5\6\7", 5),
b"\x00\x44\x32\x14\xc7"
)
def test_unpack_2(self):
self.assertEqual(
unpack(b"\x1b\xe4", 2),
b"\0\1\2\3\3\2\1\0"
)
def test_unpack_4(self):
self.assertEqual(
unpack(b"\x01\x23\x45\x67", 4),
b"\0\1\2\3\4\5\6\7"
)
def test_unpack_5(self):
self.assertEqual(
unpack(b"\x00\x44\x32\x14\xc7", 5),
b"\0\1\2\3\4\5\6\7"
)