コード例 #1
0
ファイル: nomerge_test.go プロジェクト: katydid/katydid
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)
	}
}
コード例 #2
0
ファイル: nomerge_test.go プロジェクト: katydid/katydid
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)
	}
}