func TestRoundTrip(t *testing.T) { var customerTripped ff.Customer customer := ff.NewCustomer() buf1, err := json.Marshal(&customer) if err != nil { t.Fatalf("Marshal: %v", err) } err = json.Unmarshal(buf1, &customerTripped) if err != nil { t.Fatalf("Unmarshal: %v", err) } }
func BenchmarkFFMarshalJSON(b *testing.B) { cust := ff.NewCustomer() buf, err := cust.MarshalJSON() if err != nil { b.Fatalf("Marshal: %v", err) } b.SetBytes(int64(len(buf))) b.ResetTimer() for i := 0; i < b.N; i++ { _, err := cust.MarshalJSON() if err != nil { b.Fatalf("Marshal: %v", err) } } }