mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
tests: add some DCPacker unit tests (for #751)
This commit is contained in:
parent
cb53e5d822
commit
b9713f71b1
36
tests/dcparser/test_dcpacker.py
Normal file
36
tests/dcparser/test_dcpacker.py
Normal file
@ -0,0 +1,36 @@
|
||||
import pytest
|
||||
|
||||
direct = pytest.importorskip("panda3d.direct")
|
||||
|
||||
|
||||
def test_pack_int8():
|
||||
for num in range(-128, 128):
|
||||
packer = direct.DCPacker()
|
||||
packer.raw_pack_int8(num)
|
||||
packer.set_unpack_data(packer.get_bytes())
|
||||
assert packer.raw_unpack_int8() == num
|
||||
|
||||
|
||||
def test_pack_uint8():
|
||||
for num in range(256):
|
||||
packer = direct.DCPacker()
|
||||
packer.raw_pack_uint8(num)
|
||||
packer.set_unpack_data(packer.get_bytes())
|
||||
assert packer.raw_unpack_uint8() == num
|
||||
|
||||
|
||||
def test_pack_int64():
|
||||
for num in (0, -1, 0x7fffffff, -0x80000000, 0x7fffffffffffffff, 0x7ffffffffffffffe, -0x8000000000000000, -0x7fffffffffffffff):
|
||||
packer = direct.DCPacker()
|
||||
packer.raw_pack_int64(num)
|
||||
packer.set_unpack_data(packer.get_bytes())
|
||||
assert packer.raw_unpack_int64() == num
|
||||
|
||||
|
||||
def test_pack_uint64():
|
||||
for num in (0, 1, 0x7fffffff, 0xffffffff, 0x7fffffffffffffff, 0xfffffffffffffffe, 0xffffffffffffffff):
|
||||
packer = direct.DCPacker()
|
||||
packer.raw_pack_uint64(num)
|
||||
packer.set_unpack_data(packer.get_bytes())
|
||||
assert packer.raw_unpack_uint64() == num
|
||||
|
Loading…
x
Reference in New Issue
Block a user