improve coverage (#168)

This commit is contained in:
Alessandro Ros
2023-01-06 23:34:10 +01:00
committed by GitHub
parent a759ba9d01
commit 2e88705875
195 changed files with 535 additions and 63 deletions

View File

@@ -122,46 +122,6 @@ func TestConfigUnmarshal(t *testing.T) {
}
}
func TestConfigUnmarshalErrors(t *testing.T) {
for _, ca := range []struct {
name string
enc []byte
err string
}{
{
"empty",
[]byte{},
"not enough bits",
},
{
"unsupported object type",
[]byte{0xF1},
"unsupported object type: 30",
},
{
"no sample rate index",
[]byte{0b00010000},
"not enough bits",
},
{
"invalid sample rate index",
[]byte{0b00010110, 0b10000000},
"invalid sample rate index (13)",
},
{
"channel config 0",
[]byte{0b00010100, 0b00000000},
"not yet supported",
},
} {
t.Run(ca.name, func(t *testing.T) {
var dec Config
err := dec.Unmarshal(ca.enc)
require.EqualError(t, err, ca.err)
})
}
}
func TestConfigMarshal(t *testing.T) {
for _, ca := range configCases {
t.Run(ca.name, func(t *testing.T) {
@@ -194,3 +154,10 @@ func TestConfigMarshalErrors(t *testing.T) {
})
}
}
func FuzzConfigUnmarshal(f *testing.F) {
f.Fuzz(func(t *testing.T, b []byte) {
var conf Config
conf.Unmarshal(b)
})
}