Beispiel #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,)
Beispiel #2
0
 def _read_le_uint64(self):
     result, = unpack_uint64_from(self.binary, self.cursor)
     self.cursor += 8
     return result