2021-01-13 11:07:50 +00:00
|
|
|
from pyodide_build.testing import run_in_pyodide
|
2020-12-24 17:15:35 +00:00
|
|
|
|
|
|
|
|
2021-01-13 11:07:50 +00:00
|
|
|
@run_in_pyodide(standalone=True, packages=["msgpack"])
|
|
|
|
def test_pack():
|
2022-02-21 22:27:03 +00:00
|
|
|
from msgpack import Packer, Unpacker, pack, packb, unpackb # noqa: F401
|
2020-12-24 17:15:35 +00:00
|
|
|
|
2021-01-13 11:07:50 +00:00
|
|
|
def check(data, use_list=False):
|
|
|
|
re = unpackb(packb(data), use_list=use_list, strict_map_key=False)
|
|
|
|
assert re == data
|
|
|
|
|
|
|
|
test_data = [
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
127,
|
|
|
|
128,
|
|
|
|
255,
|
|
|
|
256,
|
|
|
|
65535,
|
|
|
|
65536,
|
|
|
|
4294967295,
|
|
|
|
4294967296,
|
|
|
|
-1,
|
|
|
|
-32,
|
|
|
|
-33,
|
|
|
|
-128,
|
|
|
|
-129,
|
|
|
|
-32768,
|
|
|
|
-32769,
|
|
|
|
-4294967296,
|
|
|
|
-4294967297,
|
|
|
|
1.0,
|
|
|
|
b"",
|
|
|
|
b"a",
|
|
|
|
b"a" * 31,
|
|
|
|
b"a" * 32,
|
|
|
|
None,
|
|
|
|
True,
|
|
|
|
False,
|
|
|
|
(),
|
|
|
|
((),),
|
|
|
|
((), None),
|
|
|
|
{None: 0},
|
|
|
|
(1 << 23),
|
|
|
|
]
|
|
|
|
for td in test_data:
|
|
|
|
check(td)
|