예제 #1
0
func BenchmarkFFUnmarshalJSON(b *testing.B) {
	rec := ff.Log{}
	buf := getBaseData(b)
	b.SetBytes(int64(len(buf)))

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		err := rec.UnmarshalJSON(buf)
		if err != nil {
			b.Fatalf("UnmarshalJSON: %v", err)
		}
	}
}
예제 #2
0
func TestUnmarshal(t *testing.T) {
	rec := ff.Log{}
	buf := getBaseData(t)

	err := rec.UnmarshalJSON(buf)
	if err != nil {
		t.Fatalf("Unmarshal: %v from %s", err, string(buf))
	}

	rec2 := base.Log{}
	json.Unmarshal(buf, &rec2)

	a := fmt.Sprintf("%v", rec)
	b := fmt.Sprintf("%v", rec2)
	if a != b {
		t.Fatalf("Expected: %v\n Got: %v\n from: %s", rec2, rec, string(buf))
	}
}