Example #1
0
func TestNoMergeNestedNoMerge(t *testing.T) {
	bigm := prototests.NewPopulatedBigMsg(r, true)
	data, err := proto.Marshal(bigm)
	if err != nil {
		panic(err)
	}
	err = noMerge(data, bigm.Description(), "prototests", "BigMsg")
	if err != nil {
		t.Fatal(err)
	}
}
Example #2
0
func TestNoMergeMessageMerge(t *testing.T) {
	bigm := prototests.NewPopulatedBigMsg(r, true)
	bigm.Msg = prototests.NewPopulatedSmallMsg(r, true)
	data, err := proto.Marshal(bigm)
	if err != nil {
		panic(err)
	}
	key := byte(uint32(3)<<3 | uint32(2))
	fieldkey := byte(uint32(12)<<3 | uint32(5))
	data = append(data, key, 5, fieldkey, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
	err = noMerge(data, bigm.Description(), "prototests", "BigMsg")
	if err == nil || !strings.Contains(err.Error(), "requires merging") {
		t.Fatal(err)
	}
}
Example #3
0
func TestNoMergeNestedMerge(t *testing.T) {
	bigm := prototests.NewPopulatedBigMsg(r, true)
	m := prototests.NewPopulatedSmallMsg(r, true)
	if len(m.FlightParachute) == 0 {
		m.FlightParachute = []uint32{1}
	}
	m.MapShark = proto.String("a")
	key := byte(uint32(12)<<3 | uint32(5))
	m.XXX_unrecognized = append(m.XXX_unrecognized, key, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
	bigm.Msg = m
	data, err := proto.Marshal(bigm)
	if err != nil {
		panic(err)
	}
	err = noMerge(data, bigm.Description(), "prototests", "BigMsg")
	if err == nil || !strings.Contains(err.Error(), "FlightParachute requires merging") {
		t.Fatalf("FlightParachute should require merging %#v", bigm)
	}
}