kaitai
This commit is contained in:
1 parent
f804c327de
commit
6a32066069
21 files changed
+2028
-1
No files matched your search
@@ -0,0 +1,30 @@
|
||||
from maple.pdb.strings import EMPTY, encode_devicesql
|
||||
|
||||
|
||||
def test_empty():
|
||||
assert encode_devicesql("") == EMPTY
|
||||
|
||||
|
||||
def test_short_ascii():
|
||||
out = encode_devicesql("ON")
|
||||
# length=3 -> length_and_kind = (3<<1)|1 = 7
|
||||
assert out == bytes([7]) + b"ON"
|
||||
|
||||
|
||||
def test_longer_ascii():
|
||||
s = "Hello, World!"
|
||||
out = encode_devicesql(s)
|
||||
length = len(s) + 1
|
||||
assert out[0] == ((length << 1) | 1)
|
||||
assert out[1:] == s.encode("ascii")
|
||||
|
||||
|
||||
def test_utf16():
|
||||
s = "ЛаBа"
|
||||
out = encode_devicesql(s)
|
||||
assert out[0] == 0x90
|
||||
# Total length stored = payload_len + 4
|
||||
payload = s.encode("utf-16-le")
|
||||
assert out[1:3] == (len(payload) + 4).to_bytes(2, "little")
|
||||
assert out[3] == 0
|
||||
assert out[4:] == payload
|
||||
Reference in new issue
Block a user