def test_decode_union(self): u = TestUnion(i32_field=123) self.decode_helper(u) u.set_string_field(b"world") self.decode_helper(u) u.set_struct_field(AStruct(aString=b"world")) self.decode_helper(u) swu = StructWithUnion(aUnion=u, aString=b"world") self.decode_helper(swu)
def test_encode_union(self): u = TestUnion(i32_field=12) self.encode_helper(u) u.set_string_field("hello") self.encode_helper(u) u.set_struct_field(AStruct(aString="hello")) self.encode_helper(u) swu = StructWithUnion(aUnion=u, aString="world") self.encode_helper(swu)