Exemplo n.º 1
0
func TestNoLatentNoMerge(t *testing.T) {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	m := test.NewPopulatedNinOptNative(r, true)
	data, err := proto.Marshal(m)
	if err != nil {
		panic(err)
	}
	err = fieldpath.NoLatentAppendingOrMerging(data, test.ThetestDescription(), "test", "NinOptNative")
	if err != nil {
		panic(err)
	}
}
Exemplo n.º 2
0
func TestNoLatentMerge(t *testing.T) {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	m := test.NewPopulatedNinOptNative(r, true)
	if m.Field1 == nil {
		m.Field1 = proto.Float64(1.1)
	}
	data, err := proto.Marshal(m)
	if err != nil {
		panic(err)
	}
	key := byte(uint32(1)<<3 | uint32(1))
	data = append(data, 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)))
	err = fieldpath.NoLatentAppendingOrMerging(data, test.ThetestDescription(), "test", "NinOptNative")
	if err == nil || !strings.Contains(err.Error(), "NinOptNative.Field1") {
		t.Fatalf("Field1 should require merging")
	}
}