From 19833ff747872ba097e606e1a2067cbb94e2b1cd Mon Sep 17 00:00:00 2001 From: Hraban Luyat Date: Sun, 8 Mar 2015 22:48:22 +0000 Subject: [PATCH] More samples in encode/decode unit test --- opus_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/opus_test.go b/opus_test.go index c6ad59f..549aaae 100644 --- a/opus_test.go +++ b/opus_test.go @@ -45,7 +45,7 @@ func TestCodecFloat32(t *testing.T) { // Create bogus input sound const G4 = 391.995 const SAMPLE_RATE = 48000 - const FRAME_SIZE_MS = 10 + const FRAME_SIZE_MS = 60 const FRAME_SIZE = SAMPLE_RATE * FRAME_SIZE_MS / 1000 pcm := make([]float32, FRAME_SIZE) enc, err := NewEncoder(SAMPLE_RATE, 1, APPLICATION_VOIP) @@ -65,7 +65,10 @@ func TestCodecFloat32(t *testing.T) { if err != nil { t.Fatalf("Couldn't decode data: %v", err) } - // TODO: Well, since this is lossy, checking the output signal is not - // straightforward.. I guess a FFT could work? - _ = pcm2 + if len(pcm) != len(pcm2) { + t.Fatalf("Length mismatch: %d samples in, %d out", len(pcm), len(pcm2)) + } + // Checking the output programmatically is seriously not easy. I checked it + // by hand and by ear, it looks fine. I'll just assume the API faithfully + // passes error codes through, and that's that. } -- 2.48.1