mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 03:22:29 +00:00
Port tl-types fromm grammers
This commit is contained in:
28
client/tests/serializable_test.py
Normal file
28
client/tests/serializable_test.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from pytest import mark
|
||||
from telethon._impl.tl.core import serialize_bytes_to
|
||||
|
||||
|
||||
@mark.parametrize(
|
||||
("string", "prefix", "suffix"),
|
||||
[
|
||||
("", b"\00", b"\00\x00\x00"),
|
||||
("Hi", b"\02", b"\00"),
|
||||
("Hi!", b"\03", b""),
|
||||
("Hello", b"\05", b"\00\x00"),
|
||||
("Hello, world!", b"\x0d", b"\00\x00"),
|
||||
(
|
||||
"This is a very long string, and it has to be longer than 253 \
|
||||
characters, which are quite a few but we can make it! Although, \
|
||||
it is quite challenging. The quick brown fox jumps over the lazy \
|
||||
fox. There is still some more text we need to type. Oh, this \
|
||||
sentence made it past!",
|
||||
b"\xfe\x11\x01\x00",
|
||||
b"\x00\x00\x00",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_string(string: str, prefix: bytes, suffix: bytes) -> None:
|
||||
expected = prefix + string.encode("ascii") + suffix
|
||||
buffer = bytearray()
|
||||
serialize_bytes_to(buffer, string.encode("ascii"))
|
||||
assert bytes(buffer) == expected
|
Reference in New Issue
Block a user