def test_unpackers():
    b = bytes(range(256))
    assert util.unpack_le_int32_from(b, 0) == (50462976, )
    assert util.unpack_le_int32_from(b, 42) == (757869354, )
    assert util.unpack_le_int64_from(b, 0) == (506097522914230528, )
    assert util.unpack_le_int64_from(b, 42) == (3544384782113450794, )

    assert util.unpack_le_uint16_from(b, 0) == (256, )
    assert util.unpack_le_uint16_from(b, 42) == (11050, )
    assert util.unpack_le_uint32_from(b, 0) == (50462976, )
    assert util.unpack_le_uint32_from(b, 42) == (757869354, )
    assert util.unpack_le_uint64_from(b, 0) == (506097522914230528, )
    assert util.unpack_le_uint64_from(b, 42) == (3544384782113450794, )
Esempio n. 2
0
 def _read_le_int32(self):
     result, = unpack_le_int32_from(self.binary, self.cursor)
     self.cursor += 4
     return result
Esempio n. 3
0
 def _get_version(self):
     result, = unpack_le_int32_from(self.binary, self.cursor)
     return result
Esempio n. 4
0
def read_le_int32(buf, cursor):
    result, = unpack_le_int32_from(buf, cursor)
    return result, cursor + 4