func TestDataVersioningZeroPointersToTwo(t *testing.T) {
	t.Parallel()
	in := mustEncodeTestMessage(
		t,
		"HoldsVerTwoTwoList",
		`(mylist = [
			(val = 27, duo = 26, ptr1 = (val = 25), ptr2 = (val = 23)),
			(val = 42, duo = 41, ptr1 = (val = 40), ptr2 = (val = 38))])`,
		[]byte{
			0, 0, 0, 0, 15, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 1, 0,
			1, 0, 0, 0, 71, 0, 0, 0,
			8, 0, 0, 0, 2, 0, 2, 0,
			27, 0, 0, 0, 0, 0, 0, 0,
			26, 0, 0, 0, 0, 0, 0, 0,
			20, 0, 0, 0, 1, 0, 0, 0,
			20, 0, 0, 0, 1, 0, 0, 0,
			42, 0, 0, 0, 0, 0, 0, 0,
			41, 0, 0, 0, 0, 0, 0, 0,
			12, 0, 0, 0, 1, 0, 0, 0,
			12, 0, 0, 0, 1, 0, 0, 0,
			25, 0, 0, 0, 0, 0, 0, 0,
			23, 0, 0, 0, 0, 0, 0, 0,
			40, 0, 0, 0, 0, 0, 0, 0,
			38, 0, 0, 0, 0, 0, 0, 0,
		})

	remsg, err := capnp.Unmarshal(in)
	if err != nil {
		t.Fatal("Unmarshal:", err)
	}

	// 0 pointers
	func() {
		reHolder, err := air.ReadRootHoldsVerEmptyList(remsg)
		if err != nil {
			t.Error("ReadRootHoldsVerEmptyList:", err)
			return
		}
		list, err := reHolder.Mylist()
		if err != nil {
			t.Error("HoldsVerEmptyList.mylist:", err)
			return
		}
		if list.Len() != 2 {
			t.Errorf("len(HoldsVerEmptyList.mylist) = %d; want 2", list.Len())
		}
	}()

	// 1 pointer
	func() {
		holder, err := air.ReadRootHoldsVerOnePtrList(remsg)
		if err != nil {
			t.Error("ReadRootHoldsVerOnePtrList:", err)
			return
		}
		list, err := holder.Mylist()
		if err != nil {
			t.Error("HoldsVerOnePtrList.mylist:", err)
			return
		}
		if list.Len() != 2 {
			t.Errorf("len(HoldsVerOnePtrList.mylist) = %d; want 2", list.Len())
			return
		}
		check := func(i int, val int16) {
			p, err := list.At(i).Ptr()
			if err != nil {
				t.Errorf("HoldsVerOnePtrList.mylist[%d].ptr: %v", i, err)
				return
			}
			if p.Val() != val {
				t.Errorf("HoldsVerOnePtrList.mylist[%d].ptr.val = %d; want %d", i, p.Val(), val)
			}
		}
		check(0, 25)
		check(1, 40)
	}()

	// 2 pointers
	func() {
		holder, err := air.ReadRootHoldsVerTwoTwoPlus(remsg)
		if err != nil {
			t.Error("ReadRootHoldsVerTwoTwoPlus:", err)
			return
		}
		list, err := holder.Mylist()
		if err != nil {
			t.Error("HoldsVerTwoTwoPlus.mylist:", err)
			return
		}
		if list.Len() != 2 {
			t.Errorf("len(HoldsVerTwoTwoPlus.mylist) = %d; want 2", list.Len())
			return
		}
		check := func(i int, val1, val2 int16) {
			if p, err := list.At(i).Ptr1(); err != nil {
				t.Errorf("HoldsVerTwoTwoPlus.mylist[%d].ptr1: %v", i, err)
			} else if p.Val() != val1 {
				t.Errorf("HoldsVerTwoTwoPlus.mylist[%d].ptr1.val = %d; want %d", i, p.Val(), val1)
			}
			if p, err := list.At(i).Ptr2(); err != nil {
				t.Errorf("HoldsVerTwoTwoPlus.mylist[%d].ptr2: %v", i, err)
			} else if p.Val() != val2 {
				t.Errorf("HoldsVerTwoTwoPlus.mylist[%d].ptr2.val = %d; want %d", i, p.Val(), val2)
			}
		}
		check(0, 25, 23)
		check(1, 40, 38)
	}()
}
func TestV1DataVersioningBiggerToEmpty(t *testing.T) {
	t.Parallel()
	in := mustEncodeTestMessage(t, "HoldsVerTwoDataList", "(mylist = [(val = 27, duo = 26), (val = 42, duo = 41)])", []byte{
		0, 0, 0, 0, 7, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 1, 0,
		1, 0, 0, 0, 39, 0, 0, 0,
		8, 0, 0, 0, 2, 0, 0, 0,
		27, 0, 0, 0, 0, 0, 0, 0,
		26, 0, 0, 0, 0, 0, 0, 0,
		42, 0, 0, 0, 0, 0, 0, 0,
		41, 0, 0, 0, 0, 0, 0, 0,
	})

	remsg, err := capnp.Unmarshal(in)
	if err != nil {
		t.Fatal("Unmarshal:", err)
	}

	// 0 data
	func() {
		reHolder0, err := air.ReadRootHoldsVerEmptyList(remsg)
		if err != nil {
			t.Error("ReadRootHoldsVerEmptyList:", err)
			return
		}
		list0, err := reHolder0.Mylist()
		if err != nil {
			t.Error("HoldsVerEmptyList.mylist:", err)
			return
		}
		if list0.Len() != 2 {
			t.Errorf("len(HoldsVerEmptyList.mylist) = %d; want 2", list0.Len())
		}
	}()

	// 1 datum
	func() {
		reHolder1, err := air.ReadRootHoldsVerOneDataList(remsg)
		if err != nil {
			t.Error("ReadRootHoldsVerOneDataList:", err)
			return
		}
		list1, err := reHolder1.Mylist()
		if err != nil {
			t.Error("HoldsVerOneDataList.mylist:", err)
			return
		}
		if list1.Len() == 2 {
			if v := list1.At(0).Val(); v != 27 {
				t.Errorf("HoldsVerOneDataList.mylist[0].val = %d; want 27", v)
			}
			if v := list1.At(1).Val(); v != 42 {
				t.Errorf("HoldsVerOneDataList.mylist[1].val = %d; want 42", v)
			}
		} else {
			t.Errorf("len(HoldsVerOneDataList.mylist) = %d; want 2", list1.Len())
		}
	}()

	// 2 data
	func() {
		reHolder2, err := air.ReadRootHoldsVerTwoDataList(remsg)
		if err != nil {
			t.Error("ReadRootHoldsVerTwoDataList:", err)
			return
		}
		list2, err := reHolder2.Mylist()
		if err != nil {
			t.Error("HoldsVerTwoDataList.mylist:", err)
			return
		}
		if list2.Len() == 2 {
			if v := list2.At(0).Val(); v != 27 {
				t.Errorf("HoldsVerTwoDataList.mylist[0].val = %d; want 27", v)
			}
			if v := list2.At(0).Duo(); v != 26 {
				t.Errorf("HoldsVerTwoDataList.mylist[0].duo = %d; want 26", v)
			}
			if v := list2.At(1).Val(); v != 42 {
				t.Errorf("HoldsVerTwoDataList.mylist[1].val = %d; want 42", v)
			}
			if v := list2.At(1).Duo(); v != 41 {
				t.Errorf("HoldsVerTwoDataList.mylist[1].duo = %d; want 41", v)
			}
		} else {
			t.Errorf("len(HoldsVerTwoDataList.mylist) = %d; want 2", list2.Len())
		}
	}()
}