Пример #1
0
func TestNoLatentNoLatent(t *testing.T) {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	m := test.NewPopulatedNinRepNative(r, true)
	data, err := proto.Marshal(m)
	if err != nil {
		panic(err)
	}
	err = fieldpath.NoLatentAppendingOrMerging(data, test.ThetestDescription(), "test", "NinRepNative")
	if err != nil {
		panic(err)
	}
}
Пример #2
0
func TestNoLatentLatent(t *testing.T) {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	m := test.NewPopulatedNinRepNative(r, true)
	if m.Field1 == nil {
		m.Field1 = []float64{1.1, 1.2}
	}
	if m.Field2 == nil {
		m.Field2 = []float32{1.1, 1.2}
	}
	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", "NinRepNative")
	if err == nil || !strings.Contains(err.Error(), "NinRepNative.Field1") {
		t.Fatalf("Field1 should have latent appending")
	}
}