package utils
import (
"os"
"path/filepath"
"testing"
)
func TestWriteWAVFile(t *testing.T) {
t.Run("writes valid samples", func(t *testing.T) {
path := filepath.Join(t.TempDir(), "test.wav")
samples := []float64{0.5, -0.5, 1.5, -1.5} // includes out of bounds for clamping
err := WriteWAVFile(path, samples, 8000)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
info, err := os.Stat(path)
if err != nil || info.Size() == 0 {
t.Error("expected file to be written with data")
}
})
t.Run("fails on empty samples", func(t *testing.T) {
path := filepath.Join(t.TempDir(), "empty.wav")
err := WriteWAVFile(path, []float64{}, 8000)
if err == nil {
t.Error("expected error for empty samples")
}
})
}