def test_copy_extend2(path: str) -> bool: data1 = read_in(path) reader1 = scalgoproto.Reader(data1) root1 = reader1.root(base.Gen3In) writer = scalgoproto.Writer() root2 = writer.copy(base.Gen3Out, root1) data2 = writer.finalize(root2) reader2 = scalgoproto.Reader(data2) root3 = reader2.root(base.Gen3In) return test_extend2_part(root3)
def test_in_extend1(path: str) -> bool: data = read_in(path) r = scalgoproto.Reader(data) s = r.root(base.Gen2In) if require(s.aa, 77): return False if require(s.bb, 42): return False if require_none(s.u): return False return True
def test_in_inplace(path: str) -> bool: o = read_in(path) r = scalgoproto.Reader(o) s = r.root(base.InplaceRootIn) if require_some(s.u): return False u = s.u if require(u.u.is_monkey, True): return False monkey = u.u.monkey if require(monkey.name, "nilson"): return False if require_some(s.u2): return False u2 = s.u2 if require(u2.u.is_text, True): return False u2t = u2.u.text if require(u2t.t, "foobar"): return False if require_some(s.t): return False t = s.t if require(t.id, 45): return False if require(t.t, "cake"): return False if require_some(s.b): return False b = s.b if require(b.id, 46): return False if require(b.b, b"hi"): return False if require_some(s.l): return False l = s.l if require(l.id, 47): return False if require_some(l.l): return False ll = l.l if require(len(ll), 2): return False if require(ll[0], 24): return False if require(ll[1], 99): return False return True
def for_copy() -> union.Table3In: w = scalgoproto.Writer() root = w.construct_table(union.Table3Out) v1 = root.add_v1() v1.a.v1 = "ctext1" v1.b.v1 = "ctext2" v2 = root.add_v2() v2.a.v2 = b"cbytes1" v2.b.v2 = b"cbytes2" v3 = root.add_v3() v3.a.add_v3().a = 101 v3.b.add_v3().a = 102 v4 = root.add_v4() v4.a.add_v4().a = 103 v4.b.add_v4().a = 104 v5 = root.add_v5() v5.a.add_v5(1)[0] = "ctext3" v5.b.add_v5(1)[0] = "ctext4" v6 = root.add_v6() v6.a.add_v6(1)[0] = b"cbytes3" v6.b.add_v6(1)[0] = b"cbytes4" v7 = root.add_v7() v7.a.add_v7(1).add(0).a = 105 v7.b.add_v7(1).add(0).a = 106 v8 = root.add_v8() v8.a.add_v8(1).add(0).a = 107 v8.b.add_v8(1).add(0).a = 108 v9 = root.add_v9() v9.a.add_v9(1)[0] = 109 v9.b.add_v9(1)[0] = 110 v10 = root.add_v10() v10.a.add_v10(1)[0] = True v10.b.add_v10(1)[0] = True d = w.finalize(root) r = scalgoproto.Reader(d) return r.root(union.Table3In)
def test_in_complex2(path: str) -> bool: r = scalgoproto.Reader(read_in(path)) s = r.root(complex2.Complex2In) if require(s.u1.is_member, True): return False if require(s.u1.member.id, 42): return False if require(s.u2.is_text, True): return False if require(s.u2.text, "text"): return False if require(s.u3.is_my_bytes, True): return False if require(s.u3.my_bytes, b"bytes"): return False if require(s.u4.is_enum_list, True): return False l = s.u4.enum_list if require(len(l), 2): return False if require(l[0], base.NamedUnionEnumList.x): return False if require(l[1], base.NamedUnionEnumList.z): return False if require(s.u5.is_a, True): return False if require_some(s.hat): return False if require(s.hat.id, 43): return False if require_some(s.l): return False l2 = s.l if require(len(l2), 1): return False if require(l2[0].a, 2): return False if require(l2[0].b, True): return False if require(s.s.x, complex2.Complex2SX.p): return False if require(s.s.y.z, 8): return False return True
def test_in_union(path: str) -> bool: o = read_in(path) r = scalgoproto.Reader(o) i = r.root(union.Table3In) print(i) if require(i.has_v1, True): return False if require(i.has_v1, True): return False v1 = i.v1 if require2(v1.has_a and v1.a.is_v1, v1.a.v1, "text1"): return False if require2(v1.has_b and v1.b.is_v1, v1.b.v1, "text2"): return False if require2(v1.has_c and v1.c.is_v1, v1.c.v1, "text3"): return False if require2(v1.has_d and v1.d.is_v1, v1.d.v1, "ctext1"): return False if require2(v1.has_e and v1.e.is_v1, v1.e.v1, "ctext2"): return False if require(i.has_v2, True): return False v2 = i.v2 if require2(v2.has_a and v2.a.is_v2, v2.a.v2, b"bytes1"): return False if require2(v2.has_b and v2.b.is_v2, v2.b.v2, b"bytes2"): return False if require2(v2.has_c and v2.c.is_v2, v2.c.v2, b"bytes3"): return False if require2(v2.has_d and v2.d.is_v2, v2.d.v2, b"cbytes1"): return False if require2(v2.has_e and v2.e.is_v2, v2.e.v2, b"cbytes2"): return False if require(i.has_v3, True): return False v3 = i.v3 if require2(v3.has_a and v3.a.is_v3, v3.a.v3.a, 1): return False if require2(v3.has_b and v3.b.is_v3, v3.b.v3.a, 2): return False if require2(v3.has_c and v3.c.is_v3, v3.c.v3.a, 3): return False if require2(v3.has_d and v3.d.is_v3, v3.d.v3.a, 101): return False if require2(v3.has_e and v3.e.is_v3, v3.e.v3.a, 102): return False if require(i.has_v4, True): return False v4 = i.v4 if require2(v4.has_a and v4.a.is_v4, v4.a.v4.a, 4): return False if require2(v4.has_b and v4.b.is_v4, v4.b.v4.a, 5): return False if require2(v4.has_c and v4.c.is_v4, v4.c.v4.a, 6): return False if require2(v4.has_d and v4.d.is_v4, v4.d.v4.a, 103): return False if require2(v4.has_e and v4.e.is_v4, v4.e.v4.a, 104): return False if require(i.has_v5, True): return False v5 = i.v5 if require2(v5.has_a and v5.a.is_v5 and len(v5.a.v5) == 1, v5.a.v5[0], "text4"): return False if require2(v5.has_b and v5.b.is_v5 and len(v5.b.v5) == 1, v5.b.v5[0], "text5"): return False if require2(v5.has_c and v5.c.is_v5 and len(v5.c.v5) == 1, v5.c.v5[0], "text6"): return False if require2(v5.has_d and v5.d.is_v5 and len(v5.d.v5) == 1, v5.d.v5[0], "ctext3"): return False if require2(v5.has_e and v5.e.is_v5 and len(v5.e.v5) == 1, v5.e.v5[0], "ctext4"): return False if require(i.has_v6, True): return False v6 = i.v6 if require2(v6.has_a and v6.a.is_v6 and len(v6.a.v6) == 1, v6.a.v6[0], b"bytes4"): return False if require2(v6.has_b and v6.b.is_v6 and len(v6.b.v6) == 1, v6.b.v6[0], b"bytes5"): return False if require2(v6.has_c and v6.c.is_v6 and len(v6.c.v6) == 1, v6.c.v6[0], b"bytes6"): return False if require2(v6.has_d and v6.d.is_v6 and len(v6.d.v6) == 1, v6.d.v6[0], b"cbytes3"): return False if require2(v6.has_e and v6.e.is_v6 and len(v6.e.v6) == 1, v6.e.v6[0], b"cbytes4"): return False if require(i.has_v7, True): return False v7 = i.v7 if require2(v7.has_a and v7.a.is_v7 and len(v7.a.v7) == 1, v7.a.v7[0].a, 7): return False if require2(v7.has_b and v7.b.is_v7 and len(v7.b.v7) == 1, v7.b.v7[0].a, 8): return False if require2(v7.has_c and v7.c.is_v7 and len(v7.c.v7) == 1, v7.c.v7[0].a, 9): return False if require2(v7.has_d and v7.d.is_v7 and len(v7.d.v7) == 1, v7.d.v7[0].a, 105): return False if require2(v7.has_e and v7.e.is_v7 and len(v7.e.v7) == 1, v7.e.v7[0].a, 106): return False if require(i.has_v8, True): return False v8 = i.v8 if require2(v8.has_a and v8.a.is_v8 and len(v8.a.v8) == 1, v8.a.v8[0].a, 10): return False if require2(v8.has_b and v8.b.is_v8 and len(v8.b.v8) == 1, v8.b.v8[0].a, 11): return False if require2(v8.has_c and v8.c.is_v8 and len(v8.c.v8) == 1, v8.c.v8[0].a, 12): return False if require2(v8.has_d and v8.d.is_v8 and len(v8.d.v8) == 1, v8.d.v8[0].a, 107): return False if require2(v8.has_e and v8.e.is_v8 and len(v8.e.v8) == 1, v8.e.v8[0].a, 108): return False if require(i.has_v9, True): return False v9 = i.v9 if require2(v9.has_a and v9.a.is_v9 and len(v9.a.v9) == 1, v9.a.v9[0], 13): return False if require2(v9.has_b and v9.b.is_v9 and len(v9.b.v9) == 1, v9.b.v9[0], 14): return False if require2(v9.has_c and v9.c.is_v9 and len(v9.c.v9) == 1, v9.c.v9[0], 15): return False if require2(v9.has_d and v9.d.is_v9 and len(v9.d.v9) == 1, v9.d.v9[0], 109): return False if require2(v9.has_e and v9.e.is_v9 and len(v9.e.v9) == 1, v9.e.v9[0], 110): return False if require(i.has_v10, True): return False v10 = i.v10 if require2(v10.has_a and v10.a.is_v10 and len(v10.a.v10) == 1, v10.a.v10[0], True): return False if require2(v10.has_b and v10.b.is_v10 and len(v10.b.v10) == 1, v10.b.v10[0], False): return False if require2(v10.has_c and v10.c.is_v10 and len(v10.c.v10) == 1, v10.c.v10[0], True): return False if require2(v10.has_d and v10.d.is_v10 and len(v10.d.v10) == 1, v10.d.v10[0], True): return False if require2(v10.has_e and v10.e.is_v10 and len(v10.e.v10) == 1, v10.e.v10[0], True): return False return True
def test_in_complex3(path: str) -> bool: r = scalgoproto.Reader(read_in(path)) s = r.root(base.Complex3In) if require(s.nmember.id, 0): return False if require(s.ntext, ""): return False if require(s.nbytes, b""): return False if require(s.text, "text"): return False if require(s.my_bytes, b"bytes"): return False if require(s.member.id, 42): return False if require(len(s.nint_list), 0): return False l = s.int_list if require(len(l), 31): return False for i in range(31): if require(l[i], 100 - 2 * i): return False l2 = s.enum_list if require(l2.has(0), True): return False if require(l2.has(1), False): return False if require(l2[0], base.MyEnum.a): return False if require(len(l2), 2): return False if require(len(s.struct_list), 1): return False l4 = s.text_list if require(len(l4), 200): return False for i in range(len(l4)): if i % 2 == 0: if require(l4[i], ""): return False else: if require(l4[i], "HI THERE"): return False l5 = s.bytes_list if require(len(l5), 1): return False if require(l5[0], b"bytes"): return False l6 = s.member_list if require(len(l6), 3): return False if require(l6[0].id, 42): return False if require(l6[1].id, 0): return False if require(l6[2].id, 42): return False l6a = s.direct_member_list if require(len(l6a), 3): return False if require(l6a[0].id, 43): return False if require(l6a[1].id, 0): return False if require(l6a[2].id, 43): return False l7 = s.f32list if require(len(l7), 2): return False if require(l7[0], 0.0): return False if require(l7[1], 98.0): return False l8 = s.f64list if require(len(l8), 3): return False if require(l8[0], 0.0): return False if require(l8[1], 0.0): return False if require(l8[2], 78.0): return False l9 = s.u8list if require(len(l9), 2): return False if require(l9[0], 4): return False if require(l9[1], 0): return False l10 = s.blist if require(len(l10), 10): return False if require(l10[0], True): return False if require(l10[1], False): return False if require(l10[2], True): return False if require(l10[3], False): return False if require(l10[4], False): return False if require(l10[5], False): return False if require(l10[6], False): return False if require(l10[7], False): return False if require(l10[8], True): return False if require(l10[9], False): return False return True
def test_in_default(path: str) -> bool: r = scalgoproto.Reader(read_in(path)) s = r.root(base.SimpleIn) if require_none(s.e): return False if require(s.s.e, base.MyEnum.a): return False if require(s.s.s.x, 0): return False if require(s.s.s.y, 0.0): return False if require(s.s.s.z, False): return False if require(s.s.b, False): return False if require(s.s.u8, 0): return False if require(s.s.u16, 0): return False if require(s.s.u32, 0): return False if require(s.s.u64, 0): return False if require(s.s.i8, 0): return False if require(s.s.i16, 0): return False if require(s.s.i32, 0): return False if require(s.s.i64, 0): return False if require(s.s.f, 0): return False if require(s.s.d, 0): return False if require(s.b, False): return False if require(s.u8, 2): return False if require(s.u16, 3): return False if require(s.u32, 4): return False if require(s.u64, 5): return False if require(s.i8, 6): return False if require(s.i16, 7): return False if require(s.i32, 8): return False if require(s.i64, 9): return False if require(s.f, 10.0): return False if require(s.d, 11.0): return False if require_none(s.os): return False if require_none(s.ob): return False if require_none(s.ou8): return False if require_none(s.ou16): return False if require_none(s.ou32): return False if require_none(s.ou64): return False if require_none(s.oi8): return False if require_none(s.oi16): return False if require_none(s.oi32): return False if require_none(s.oi64): return False if require_none(s.of): return False if require_none(s.od): return False if require_none(s.ns): return False if require_none(s.nb): return False if require_none(s.nu8): return False if require_none(s.nu16): return False if require_none(s.nu32): return False if require_none(s.nu64): return False if require_none(s.ni8): return False if require_none(s.ni16): return False if require_none(s.ni32): return False if require_none(s.ni64): return False if require_none(s.nf): return False if require_none(s.nd): return False return True
def test_in(path: str) -> bool: r = scalgoproto.Reader(read_in(path)) s = r.root(base.SimpleIn) if require_some(s.e): return False if require(s.e, base.MyEnum.c): return False if require(s.s.e, base.MyEnum.d): return False if require(s.s.s.x, 42): return False if require(s.s.s.y, 27.0): return False if require(s.s.s.z, True): return False if require(s.s.b, False): return False if require(s.s.u8, 8): return False if require(s.s.u16, 9): return False if require(s.s.u32, 10): return False if require(s.s.u64, 11): return False if require(s.s.i8, -8): return False if require(s.s.i16, -9): return False if require(s.s.i32, -10): return False if require(s.s.i64, -11): return False if require(s.s.f, 27.0): return False if require(s.s.d, 22.0): return False if require(s.b, True): return False if require(s.u8, 242): return False if require(s.u16, 4024): return False if require(s.u32, 124474): return False if require(s.u64, 5465778): return False if require(s.i8, -40): return False if require(s.i16, 4025): return False if require(s.i32, 124475): return False if require(s.i64, 5465779): return False if require(s.f, 2.0): return False if require(s.d, 3.0): return False if require_some(s.os): return False if require_some(s.ob): return False if require_some(s.ou8): return False if require_some(s.ou16): return False if require_some(s.ou32): return False if require_some(s.ou64): return False if require_some(s.oi8): return False if require_some(s.oi16): return False if require_some(s.oi32): return False if require_some(s.oi64): return False if require_some(s.of): return False if require_some(s.od): return False if require(s.os.x, 43): return False if require(s.os.y, 28.0): return False if require(s.os.z, False): return False if require(s.ob, False): return False if require(s.ou8, 252): return False if require(s.ou16, 4034): return False if require(s.ou32, 124464): return False if require(s.ou64, 5465768): return False if require(s.oi8, -60): return False if require(s.oi16, 4055): return False if require(s.oi32, 124465): return False if require(s.oi64, 5465729): return False if require(s.of, 5.0): return False if require(s.od, 6.4): return False if require_none(s.ne): return False if require_none(s.ns): return False if require_none(s.nb): return False if require_none(s.nu8): return False if require_none(s.nu16): return False if require_none(s.nu32): return False if require_none(s.nu64): return False if require_none(s.ni8): return False if require_none(s.ni16): return False if require_none(s.ni32): return False if require_none(s.ni64): return False if require_none(s.nf): return False if require_none(s.nd): return False return True
def test_in_extend2(path: str) -> bool: o = read_in(path) r = scalgoproto.Reader(o) s = r.root(base.Gen3In) return test_extend2_part(s)
def test_in_extend2(path: str) -> bool: o = read_in(path) r = scalgoproto.Reader(o) s = r.root(base.Gen3In) if require(s.aa, 80): return False if require(s.bb, 81): return False if require(s.u.is_cake, True): return False if require(s.u.cake.v, 45): return False if require(s.e, base.MyEnum.c): return False if require(s.s.x, 0): return False if require(s.s.y, 0): return False if require(s.s.z, 0): return False if require(s.b, False): return False if require(s.u8, 2): return False if require(s.u16, 3): return False if require(s.u32, 4): return False if require(s.u64, 5): return False if require(s.i8, 6): return False if require(s.i16, 7): return False if require(s.i32, 8): return False if require(s.i64, 9): return False if require(s.f, 10): return False if require(s.d, 11): return False if require(s.has_os, False): return False if require(s.has_ob, False): return False if require(s.has_ou8, False): return False if require(s.has_ou16, False): return False if require(s.has_ou32, False): return False if require(s.has_ou64, False): return False if require(s.has_oi8, False): return False if require(s.has_oi16, False): return False if require(s.has_oi32, False): return False if require(s.has_oi64, False): return False if require(s.has_of, False): return False if require(s.has_od, False): return False if require(s.has_member, False): return False if require(s.has_text, False): return False if require(s.has_mbytes, False): return False if require(s.has_int_list, False): return False if require(s.has_enum_list, False): return False if require(s.has_struct_list, False): return False if require(s.has_text_list, False): return False if require(s.has_bytes_list, False): return False if require(s.has_member_list, False): return False return True
def test_in_default(path: str) -> bool: r = scalgoproto.Reader(read_in(path)) s = r.root(base.SimpleIn) if require(s.has_e, False): return False if require(s.s.e, base.MyEnum.a): return False if require(s.s.s.x, 0): return False if require(s.s.s.y, 0.0): return False if require(s.s.s.z, False): return False if require(s.s.b, False): return False if require(s.s.u8, 0): return False if require(s.s.u16, 0): return False if require(s.s.u32, 0): return False if require(s.s.u64, 0): return False if require(s.s.i8, 0): return False if require(s.s.i16, 0): return False if require(s.s.i32, 0): return False if require(s.s.i64, 0): return False if require(s.s.f, 0): return False if require(s.s.d, 0): return False if require(s.b, False): return False if require(s.u8, 2): return False if require(s.u16, 3): return False if require(s.u32, 4): return False if require(s.u64, 5): return False if require(s.i8, 6): return False if require(s.i16, 7): return False if require(s.i32, 8): return False if require(s.i64, 9): return False if require(s.f, 10.0): return False if require(s.d, 11.0): return False if require(s.has_os, False): return False if require(s.has_ob, False): return False if require(s.has_ou8, False): return False if require(s.has_ou16, False): return False if require(s.has_ou32, False): return False if require(s.has_ou64, False): return False if require(s.has_oi8, False): return False if require(s.has_oi16, False): return False if require(s.has_oi32, False): return False if require(s.has_oi64, False): return False if require(s.has_of, False): return False if require(s.has_od, False): return False if require(s.has_ns, False): return False if require(s.has_nb, False): return False if require(s.has_nu8, False): return False if require(s.has_nu16, False): return False if require(s.has_nu32, False): return False if require(s.has_nu64, False): return False if require(s.has_ni8, False): return False if require(s.has_ni16, False): return False if require(s.has_ni32, False): return False if require(s.has_ni64, False): return False if require(s.has_nf, False): return False if require(s.has_nd, False): return False return True
def test_in(path: str) -> bool: r = scalgoproto.Reader(read_in(path)) s = r.root(base.SimpleIn) if require(s.has_e, True): return False if require(s.e, base.MyEnum.c): return False if require(s.s.e, base.MyEnum.d): return False if require(s.s.s.x, 42): return False if require(s.s.s.y, 27.0): return False if require(s.s.s.z, True): return False if require(s.s.b, False): return False if require(s.s.u8, 8): return False if require(s.s.u16, 9): return False if require(s.s.u32, 10): return False if require(s.s.u64, 11): return False if require(s.s.i8, -8): return False if require(s.s.i16, -9): return False if require(s.s.i32, -10): return False if require(s.s.i64, -11): return False if require(s.s.f, 27.0): return False if require(s.s.d, 22.0): return False if require(s.b, True): return False if require(s.u8, 242): return False if require(s.u16, 4024): return False if require(s.u32, 124474): return False if require(s.u64, 5465778): return False if require(s.i8, -40): return False if require(s.i16, 4025): return False if require(s.i32, 124475): return False if require(s.i64, 5465779): return False if require(s.f, 2.0): return False if require(s.d, 3.0): return False if require(s.has_os, True): return False if require(s.has_ob, True): return False if require(s.has_ou8, True): return False if require(s.has_ou16, True): return False if require(s.has_ou32, True): return False if require(s.has_ou64, True): return False if require(s.has_oi8, True): return False if require(s.has_oi16, True): return False if require(s.has_oi32, True): return False if require(s.has_oi64, True): return False if require(s.has_of, True): return False if require(s.has_od, True): return False if require(s.os.x, 43): return False if require(s.os.y, 28.0): return False if require(s.os.z, False): return False if require(s.ob, False): return False if require(s.ou8, 252): return False if require(s.ou16, 4034): return False if require(s.ou32, 124464): return False if require(s.ou64, 5465768): return False if require(s.oi8, -60): return False if require(s.oi16, 4055): return False if require(s.oi32, 124465): return False if require(s.oi64, 5465729): return False if require(s.of, 5.0): return False if require(s.od, 6.4): return False if require(s.has_ne, False): return False if require(s.has_ns, False): return False if require(s.has_nb, False): return False if require(s.has_nu8, False): return False if require(s.has_nu16, False): return False if require(s.has_nu32, False): return False if require(s.has_nu64, False): return False if require(s.has_ni8, False): return False if require(s.has_ni16, False): return False if require(s.has_ni32, False): return False if require(s.has_ni64, False): return False if require(s.has_nf, False): return False if require(s.has_nd, False): return False return True