diff --git a/opus_test.go b/opus_test.go index 177dde8..7db698a 100644 --- a/opus_test.go +++ b/opus_test.go @@ -86,6 +86,8 @@ func TestCodecFloat32(t *testing.T) { } addSineFloat32(pcm, SAMPLE_RATE, G4) err = enc.EncodeFloat32(pcm) + enc.Close() + if err != nil { t.Fatalf("Couldn't encode data: %v", err) } @@ -95,11 +97,16 @@ func TestCodecFloat32(t *testing.T) { } // TODO: Uh-oh.. it looks like I forgot to put a data = data[:n] here, yet // the test is not failing. Why? - n, err := dec.ReadFloat32(pcm) - if err != nil { - t.Fatalf("Couldn't decode data: %v", err) + var out []float32 + buf := make([]float32, 120*SAMPLE_RATE) + for { + n, err := dec.ReadFloat32(pcm) + if err != nil { + break + } + out = append(out, buf[:n]...) } - if len(pcm) != n { - t.Fatalf("Length mismatch: %d samples in, %d out", len(pcm), n) + if len(out) != len(pcm) { + t.Fatalf("Length mismatch: %d samples in, %d out", len(out), len(pcm)) } }