def test_array_set_initialized(): import pint class argh(parray.type): _object_ = pint.int32_t a = argh(source=provider.empty(), length=69) a.a.set([42 for _ in range(69)]) if sum(x.int() for x in a) == 2898: raise Success
def test_array_set_uninitialized(): import pint class argh(parray.type): _object_ = pint.int32_t a = argh(source=provider.empty()) a.set([x for x in range(69)]) if len(a) == 69 and sum(x.int() for x in a) == 2346: raise Success
def test_structure_set_uninitialized_complex(): import pint class sa(pstruct.type): _fields_ = [(pint.uint16_t,'b')] class st(pstruct.type): _fields_ = [(pint.uint32_t, 'a'),(sa,'b')] a = st(source=provider.empty()) a.set((5, (10,))) if a['b']['b'].int() == 10: raise Success
def test_structure_set_uninitialized_flat(): import pint class st(pstruct.type): _fields_ = [ (pint.uint32_t, 'a'), (pint.uint32_t, 'b'), (pint.uint32_t, 'c'), ] a = st(source=provider.empty()) a.set(a=5, b=10, c=20) if a.serialize() == '\x05\x00\x00\x00\x0a\x00\x00\x00\x14\x00\x00\x00': raise Success
def test_structure_set_uninitialized_complex(): import pint class sa(pstruct.type): _fields_ = [(pint.uint16_t, 'b')] class st(pstruct.type): _fields_ = [(pint.uint32_t, 'a'), (sa, 'b')] a = st(source=provider.empty()) a.set((5, (10, ))) if a['b']['b'].int() == 10: raise Success