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) } }
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) } }