def test_unpack_short_strings(): assert unpack(b"\x41\x61") == ("a", b"") assert unpack(b"\x43\x61\x62\x63") == ("abc", b"") assert unpack(b"\x60" + (0x20 * b"\x61")) == (0x20 * "a", b"")
def test_unpack_longer_strings(): assert unpack(b"\x61\x21" + (33 * b"\x61")) == (33 * "a", b"") assert unpack(b"\x62\x00\x01" + (256 * b"\x61")) == (256 * "a", b"")
def test_pack_unfloat32(): assert unpack(b"\x35\x00\x00\x80\x3f") == (1.0, b"")
def test_unpack_float64(): assert unpack(b"\x36\x00\x00\x00\x00\x00\x00\xF0\x3F") == (1.0, b"")
def test_unpack_small_integers(): assert unpack(b"\x08") == (0, b"") assert unpack(b"\x17") == (0xF, b"") assert unpack(b"\x2F") == (0x27, b"")
def test_unpack_larger_integers(): assert unpack(b"\x30\x28") == (0x28, b"") assert unpack(b"\x31\xFf\x01") == (0x1FF, b"") assert unpack(b"\x32\xFF\xFF\x01") == (0x1FFFF, b"") assert unpack(b"\x33\xFF\xFF\xFF\x01") == (0x1FFFFFF, b"")
def test_unpack_absolute_time(): # TODO: This is not implemented, it only parses the time stamp as an integer assert unpack(b"\x06\x01\x00\x00\x00\x00\x00\x00\x00") == (1, b"")
def test_unpack_uuid(): assert unpack(b"\x05\x124Vx\x124Vx\x124Vx\x124Vx") == ( UUID("{12345678-1234-5678-1234-567812345678}"), b"", )
def test_unpack_none(): assert unpack(b"\x04") == (None, b"")
def test_unpack_boolean(): assert unpack(b"\x01") == (True, b"") assert unpack(b"\x02") == (False, b"")
def test_unpack_unsupported_type(): with pytest.raises(TypeError): unpack(b"\x00")