github.com/bluenviron/mediacommon@v1.9.3/pkg/codecs/jpeg/define_restart_interval_test.go (about) 1 package jpeg 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 var casesDefineRestartInterval = []struct { 10 name string 11 enc []byte 12 dec DefineRestartInterval 13 }{ 14 { 15 "base", 16 []byte{ 17 0xff, MarkerDefineRestartInterval, 0x00, 0x04, 0xd0, 0xc7, 18 }, 19 DefineRestartInterval{ 20 Interval: 53447, 21 }, 22 }, 23 } 24 25 func TestDefineRestartIntervalUnmarshal(t *testing.T) { 26 for _, ca := range casesDefineRestartInterval { 27 t.Run(ca.name, func(t *testing.T) { 28 var h DefineRestartInterval 29 err := h.Unmarshal(ca.enc[4:]) 30 require.NoError(t, err) 31 require.Equal(t, ca.dec, h) 32 }) 33 } 34 } 35 36 func FuzzDefineRestartIntervalUnmarshal(f *testing.F) { 37 f.Fuzz(func(_ *testing.T, b []byte) { 38 var h DefineRestartInterval 39 h.Unmarshal(b) //nolint:errcheck 40 }) 41 }