mirror of
https://gitea.tendokyu.moe/eamuse/eaapi.git
synced 2024-12-18 08:55:53 +01:00
36 lines
938 B
Python
36 lines
938 B
Python
|
import unittest
|
||
|
|
||
|
from eaapi.encoder import Encoder
|
||
|
|
||
|
|
||
|
class TestEncoder(unittest.TestCase):
|
||
|
def test_packed_names(self):
|
||
|
encoder = Encoder()
|
||
|
encoder._compressed = True
|
||
|
|
||
|
encoder._write_metadata_name("the_quick_brown_fox")
|
||
|
|
||
|
self.assertEqual(
|
||
|
encoder.stream.getvalue(),
|
||
|
b"\x13\xe6\xda\xa5\xdb\xab\xa8\xc2\x59\xf7\xd3\xcc\xe5\xaf\x4f\x40"
|
||
|
)
|
||
|
|
||
|
def test_short_ascii_names(self):
|
||
|
encoder = Encoder()
|
||
|
|
||
|
encoder._write_metadata_name("the_quick_brown_fox")
|
||
|
|
||
|
self.assertEqual(
|
||
|
encoder.stream.getvalue(),
|
||
|
b"\x52the_quick_brown_fox"
|
||
|
)
|
||
|
|
||
|
def test_long_ascii_names(self):
|
||
|
encoder = Encoder()
|
||
|
|
||
|
encoder._write_metadata_name("the_quick_brown_fox_" * 10)
|
||
|
|
||
|
value = encoder.stream.getvalue()
|
||
|
self.assertEqual(value[:2], b"\x80\x87")
|
||
|
self.assertEqual(value[2:], b"the_quick_brown_fox_" * 10)
|