Esempio n. 1
0
func BenchmarkUnmarshalNinOptStructWhole(b *testing.B) {
	r := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
	for i := 0; i < b.N; i++ {
		b.StopTimer()
		p := test.NewPopulatedNinOptStruct(r, false)
		data, err := proto.Marshal(p)
		if err != nil {
			panic(err)
		}
		b.StartTimer()
		pp := &test.NinOptStruct{}
		proto.Unmarshal(data, pp)
	}
}
Esempio n. 2
0
func TestString(t *testing.T) {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	s := test.NewPopulatedNinOptStruct(r, false)
	data, err := proto.Marshal(s)
	if err != nil {
		panic(err)
	}
	buf := bytes.NewBuffer(nil)
	err = fieldpath.ToString("test", "NinOptStruct", test.ThetestDescription(), "", data, 0, os.Stdout)
	if err != nil {
		panic(err)
	}
	_ = buf
	t.Logf("%v", string(buf.Bytes()))
}
Esempio n. 3
0
func TestCodec(t *testing.T) {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	in := test.NewPopulatedNinOptStruct(r, true)
	c := New(r.Intn(1024))
	data, err := c.Marshal(in)
	if err != nil {
		t.Fatal(err)
	}
	out := &test.NinOptStruct{}
	err = c.Unmarshal(data, out)
	if err != nil {
		t.Fatal(err)
	}
	if err := in.VerboseEqual(out); err != nil {
		t.Fatal(err)
	}
}