Skip to content

Commit

Permalink
Test the retrieved samples are correct after flac.Seek()
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkKremer committed Aug 3, 2024
1 parent 87e14b9 commit 9019b85
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions flac/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func TestDecoder_Seek(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, seekPos, flacStream.Position())

wavSamples := testtools.CollectNum(100, wavStream)
flacSamples := testtools.CollectNum(100, flacStream)
assert.Equal(t, wavSamples, flacSamples)

// Test middle of 2nd frame
seekPos = (int(frameStarts[1]) + int(frameStarts[2])) / 2
err = wavStream.Seek(seekPos)
Expand All @@ -70,6 +74,10 @@ func TestDecoder_Seek(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, seekPos, flacStream.Position())

wavSamples = testtools.CollectNum(100, wavStream)
flacSamples = testtools.CollectNum(100, flacStream)
assert.Equal(t, wavSamples, flacSamples)

// Test end of 2nd frame
seekPos = int(frameStarts[2]) - 1
err = wavStream.Seek(seekPos)
Expand All @@ -78,6 +86,10 @@ func TestDecoder_Seek(t *testing.T) {
err = flacStream.Seek(seekPos)
assert.NoError(t, err)
assert.Equal(t, seekPos, flacStream.Position())

wavSamples = testtools.CollectNum(100, wavStream)
flacSamples = testtools.CollectNum(100, flacStream)
assert.Equal(t, wavSamples, flacSamples)
}

func getFlacFrameStartPositions(r io.Reader) ([]uint64, error) {
Expand Down

0 comments on commit 9019b85

Please sign in to comment.