Fix TestCodecFloat32
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
DataHoarder 2022-07-21 15:06:34 +02:00
parent d0c3e3e655
commit 3d5460c48a
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk

View file

@ -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))
}
}