def test_structure_alloc_instance(): import pint class st(pstruct.type): _fields_ = [(pint.uint16_t,'a'),(pint.uint32_t,'b')] a = st().alloc(a=pint.uint32_t().set(0x0d0e0a0d),b=0x0d0e0a0d) if a['a'].int() == 0x0d0e0a0d and a['b'].int() == 0x0d0e0a0d: raise Success
def test_array_set_initialized_instance(): import pint,ptype b = ptype.clone(parray.type,_object_=pint.uint8_t,length=4) a = parray.type(_object_=pint.uint8_t,length=4).a a.set(tuple(pint.uint32_t().set(0x40) for x in range(4))) if sum(x.int() for x in a) == 256: raise Success
def test_array_set_initialized_instance(): import pint, ptype b = ptype.clone(parray.type, _object_=pint.uint8_t, length=4) a = parray.type(_object_=pint.uint8_t, length=4).a a.set(tuple(pint.uint32_t().set(0x40) for x in range(4))) if sum(x.int() for x in a) == 256: raise Success
def test_structure_set_initialized_instance(): import pint class st(pstruct.type): _fields_ = [ (pint.int_t, 'a'), ] a = st().a.set(a=pint.uint32_t().set(20)) if a['a'].size() == 4 and a['a'].int() == 20: raise Success
def test_structure_alloc_instance(): import pint class st(pstruct.type): _fields_ = [(pint.uint16_t, 'a'), (pint.uint32_t, 'b')] a = st().alloc(a=pint.uint32_t().set(0x0d0e0a0d), b=0x0d0e0a0d) if a['a'].int() == 0x0d0e0a0d and a['b'].int() == 0x0d0e0a0d: raise Success
def test_int_revert_littleendian_uint32_load(): pint.setbyteorder(config.byteorder.littleendian) a = pint.uint32_t(source=provider.string(string2)).l if a.int() == 0x0abcdef0 and a.serialize() == string2: raise Success print a, repr(a.serialize())