func TestBitList(t *testing.T) { t.Parallel() for _, test := range bitListTests { msg, err := test.makeMessage() if err != nil { t.Errorf("%v: make message: %v", test.list, err) continue } z, err := air.ReadRootZ(msg) if err != nil { t.Errorf("%v: read root Z: %v", test.list, err) continue } if w := z.Which(); w != air.Z_Which_boolvec { t.Errorf("%v: root.Which() = %v; want boolvec", test.list, w) continue } list, err := z.Boolvec() if err != nil { t.Errorf("%v: read Z.boolvec: %v", test.list, err) continue } if n := list.Len(); n != len(test.list) { t.Errorf("%v: len(Z.boolvec) = %d; want %d", test.list, n, len(test.list)) continue } for i := range test.list { if li := list.At(i); li != test.list[i] { t.Errorf("%v: Z.boolvec[%d] = %t; want %t", test.list, i, li, test.list[i]) } } } }
func TestZDataAccessors(t *testing.T) { t.Parallel() data := mustEncodeTestMessage(t, "Z", `(zdata = (data = "\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13"))`, []byte{ 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 162, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, 0, 0, }) msg, err := capnp.Unmarshal(data) if err != nil { t.Fatal("Unmarshal:", err) } z, err := air.ReadRootZ(msg) if err != nil { t.Fatal("ReadRootZ:", err) } if z.Which() != air.Z_Which_zdata { t.Fatalf("z.Which() = %v; want zdata", z.Which()) } zdata, err := z.Zdata() if err != nil { t.Fatal("z.Zdata():", err) } d, err := zdata.Data() if err != nil { t.Fatal("z.Zdata().Data():", err) } if len(d) != 20 { t.Errorf("z.Zdata().Data() len = %d; want 20", len(d)) } for i := range d { if d[i] != byte(i) { t.Errorf("z.Zdata().Data()[%d] = %d; want %d", i, d[i], i) } } }