further samplerate tests

This commit is contained in:
Rob Watson 2021-01-27 07:33:16 +01:00
parent 2171eba4c9
commit bbd3dd881e
1 changed files with 36 additions and 0 deletions

View File

@ -6,6 +6,42 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestHasSyncWord(t *testing.T) {
testCases := []struct {
name string
bytes []byte
expResult bool
}{
{
"empty header",
[]byte{0, 0, 0, 0},
false,
},
{
"almost",
[]byte{0xff, 0xc0, 0, 0},
false,
},
{
"present",
[]byte{0xff, 0xe0, 0, 0},
true,
},
{
"full header",
[]byte{0xff, 0xff, 0xff, 0xff},
true,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
h := header(tc.bytes)
assert.Equal(t, tc.expResult, h.HasSyncWord())
})
}
}
func TestAudioVersionId(t *testing.T) { func TestAudioVersionId(t *testing.T) {
bytes := []byte{0xff, 0xe8, 0, 0} bytes := []byte{0xff, 0xe8, 0, 0}
h := header(bytes) h := header(bytes)