Пример #1
0
def test_unpackers():
    b = bytes(range(256))
    assert util.unpack_int32_from(b, 0) == (50462976, )
    assert util.unpack_int32_from(b, 42) == (757869354, )
    assert util.unpack_int64_from(b, 0) == (506097522914230528, )
    assert util.unpack_int64_from(b, 42) == (3544384782113450794, )

    assert util.unpack_uint16_from(b, 0) == (256, )
    assert util.unpack_uint16_from(b, 42) == (11050, )
    assert util.unpack_uint32_from(b, 0) == (50462976, )
    assert util.unpack_uint32_from(b, 42) == (757869354, )
    assert util.unpack_uint64_from(b, 0) == (506097522914230528, )
    assert util.unpack_uint64_from(b, 42) == (3544384782113450794, )
Пример #2
0
 def _read_le_uint16(self):
     result, = unpack_uint16_from(self.binary, self.cursor)
     self.cursor += 2
     return result