forked from TrueCloudLab/policy-engine
35 lines
605 B
Go
35 lines
605 B
Go
|
//go:build gofuzz
|
||
|
// +build gofuzz
|
||
|
|
||
|
package chain
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/require"
|
||
|
)
|
||
|
|
||
|
func FuzzUnmarshal(f *testing.F) {
|
||
|
for _, id := range generateTestIDs() {
|
||
|
for _, rules := range generateTestRules() {
|
||
|
for _, matchType := range generateTestMatchTypes() {
|
||
|
|
||
|
chain := Chain{
|
||
|
ID: id,
|
||
|
Rules: rules,
|
||
|
MatchType: matchType,
|
||
|
}
|
||
|
data, err := chain.MarshalBinary()
|
||
|
require.NoError(f, err)
|
||
|
f.Add(data)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
f.Fuzz(func(t *testing.T, data []byte) {
|
||
|
require.NotPanics(t, func() {
|
||
|
DoFuzzChainUnmarshalBinary(data)
|
||
|
})
|
||
|
})
|
||
|
}
|