move codec-specific utilities into pkg/codecs

This commit is contained in:
aler9
2022-12-27 17:19:56 +01:00
parent 68d617ef51
commit aca56089c1
42 changed files with 11 additions and 9 deletions

View File

@@ -0,0 +1,42 @@
package jpeg
import (
"testing"
"github.com/stretchr/testify/require"
)
var casesStartOfScan = []struct {
name string
enc []byte
dec StartOfScan
}{
{
"base",
[]byte{
0xff, 0xda, 0x0, 0xc, 0x3, 0x0, 0x0, 0x1,
0x11, 0x2, 0x11, 0x0, 0x3f, 0x0,
},
StartOfScan{},
},
}
func TestStartOfScanUnmarshal(t *testing.T) {
for _, ca := range casesStartOfScan {
t.Run(ca.name, func(t *testing.T) {
var h StartOfScan
err := h.Unmarshal(ca.enc[4:])
require.NoError(t, err)
require.Equal(t, ca.dec, h)
})
}
}
func TestStartOfScanMarshal(t *testing.T) {
for _, ca := range casesStartOfScan {
t.Run(ca.name, func(t *testing.T) {
byts := ca.dec.Marshal(nil)
require.Equal(t, ca.enc, byts)
})
}
}