def test_int_littleendian_int32_unsigned_lowedge_load(): pint.setbyteorder(config.byteorder.littleendian) s = '\x00\x00\x00\x00' a = pint.int32_t(source=provider.string(s)).l b, = struct.unpack('i',s) if a.int() == b and a.serialize() == s: raise Success print b, a, a.serialize().encode('hex')
def test_int_littleendian_int32_unsigned_load(): pint.setbyteorder(config.byteorder.littleendian) s = b'\x00\x00\x00\x80' a = pint.int32_t(source=provider.bytes(s)).l b, = struct.unpack('i',s) if a.int() == b and a.serialize() == s: raise Success print(b, a, tohex(a.serialize()))
def test_structure_alloc_dynamic_instance(): class st(pstruct.type): def __b(self): return ptype.clone(pint.int_t, length=self['a'].li.int()) _fields_ = [ (pint.int_t, 'a'), (__b, 'b'), ] a = st().alloc(a=pint.int32_t().set(4)) if a['b'].size() == a['a'].int(): raise Success
def test_structure_alloc_dynamic_instance(): class st(pstruct.type): def __b(self): return ptype.clone(pint.int_t, length=self['a'].li.int()) _fields_ = [ (pint.int_t, 'a'), (__b, 'b'), ] a = st().alloc(a=pint.int32_t().set(4)) if a['b'].size() == a['a'].int(): raise Success