func TestNoMergeNestedNoMerge(t *testing.T) { r := rand.New(rand.NewSource(time.Now().UnixNano())) bigm := test.NewPopulatedNidOptStruct(r, true) data, err := proto.Marshal(bigm) if err != nil { panic(err) } err = fieldpath.NoMerge(data, test.ThetestDescription(), "test", "NidOptStruct") if err != nil { panic(err) } }
func TestNoMergeMessageMerge(t *testing.T) { r := rand.New(rand.NewSource(time.Now().UnixNano())) bigm := test.NewPopulatedNidOptStruct(r, true) data, err := proto.Marshal(bigm) if err != nil { panic(err) } key := byte(uint32(4)<<3 | uint32(2)) data = append(data, key, 5, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) err = fieldpath.NoMerge(data, test.ThetestDescription(), "test", "NidOptStruct") if err == nil || !strings.Contains(err.Error(), "requires merging") { panic(err) } }
func TestNoMergeNestedMerge(t *testing.T) { r := rand.New(rand.NewSource(time.Now().UnixNano())) bigm := test.NewPopulatedNidOptStruct(r, true) m := test.NewPopulatedNinOptNative(r, true) if m.Field1 == nil { m.Field1 = proto.Float64(1.1) } key := byte(uint32(1)<<3 | uint32(1)) m.XXX_unrecognized = append(m.XXX_unrecognized, key, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) bigm.Field4 = *m data, err := proto.Marshal(bigm) if err != nil { panic(err) } err = fieldpath.NoMerge(data, test.ThetestDescription(), "test", "NidOptStruct") if err == nil || !strings.Contains(err.Error(), "NinOptNative.Field1 requires merging") { t.Fatalf("Field1 should require merging") } }