diff --git a/main_test.go b/main_test.go index 63140ea..955e520 100644 --- a/main_test.go +++ b/main_test.go @@ -6,6 +6,42 @@ import ( "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) { bytes := []byte{0xff, 0xe8, 0, 0} h := header(bytes)