This commit is contained in:
parent
d0c3e3e655
commit
3d5460c48a
17
opus_test.go
17
opus_test.go
|
@ -86,6 +86,8 @@ func TestCodecFloat32(t *testing.T) {
|
||||||
}
|
}
|
||||||
addSineFloat32(pcm, SAMPLE_RATE, G4)
|
addSineFloat32(pcm, SAMPLE_RATE, G4)
|
||||||
err = enc.EncodeFloat32(pcm)
|
err = enc.EncodeFloat32(pcm)
|
||||||
|
enc.Close()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Couldn't encode data: %v", err)
|
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
|
// TODO: Uh-oh.. it looks like I forgot to put a data = data[:n] here, yet
|
||||||
// the test is not failing. Why?
|
// the test is not failing. Why?
|
||||||
n, err := dec.ReadFloat32(pcm)
|
var out []float32
|
||||||
if err != nil {
|
buf := make([]float32, 120*SAMPLE_RATE)
|
||||||
t.Fatalf("Couldn't decode data: %v", err)
|
for {
|
||||||
|
n, err := dec.ReadFloat32(pcm)
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
out = append(out, buf[:n]...)
|
||||||
}
|
}
|
||||||
if len(pcm) != n {
|
if len(out) != len(pcm) {
|
||||||
t.Fatalf("Length mismatch: %d samples in, %d out", len(pcm), n)
|
t.Fatalf("Length mismatch: %d samples in, %d out", len(out), len(pcm))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue