Esempio n. 1
0
// Fuzz is a test for the generated code.
// See https://github.com/dvyukov/go-fuzz
func Fuzz(data []byte) int {
	o := new(gen.O)
	err := o.UnmarshalBinary(data)
	if err != nil {
		return 0
	}

	_, err = o.MarshalBinary()
	if err != nil {
		panic(err)
	}
	return 1
}
Esempio n. 2
0
func TestUnmarshal(t *testing.T) {
	for _, gold := range newGoldenCases() {
		data, err := hex.DecodeString(gold.serial)
		if err != nil {
			t.Fatal(err)
		}

		got := gen.O{}
		if err := got.UnmarshalBinary(data); err != nil {
			t.Errorf("0x%s: %s", gold.serial, err)
			continue
		}
		verify.Values(t, fmt.Sprintf("0x%s", gold.serial), got, gold.object)
	}
}