mirror of https://github.com/pyodide/pyodide.git
51 lines
759 B
Python
51 lines
759 B
Python
|
def test_pack(selenium_standalone):
|
||
|
selenium = selenium_standalone
|
||
|
selenium.load_package(["msgpack"])
|
||
|
selenium.run(
|
||
|
"""
|
||
|
from msgpack import packb, unpackb, Unpacker, Packer, pack
|
||
|
|
||
|
|
||
|
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)
|
||
|
"""
|
||
|
)
|