|
- package offline
-
- import (
- "os"
- "path/filepath"
- "strings"
- "testing"
- "time"
-
- cfgpkg "github.com/jan/fm-rds-tx/internal/config"
- )
-
- func TestGenerateFrame(t *testing.T) {
- g := NewGenerator(cfgpkg.Default())
- frame := g.GenerateFrame(50 * time.Millisecond)
- if frame == nil {
- t.Fatal("expected frame")
- }
- if len(frame.Samples) == 0 {
- t.Fatal("expected samples")
- }
- }
-
- func TestWriteFile(t *testing.T) {
- cfg := cfgpkg.Default()
- out := filepath.Join(t.TempDir(), "test.iqf32")
- cfg.Backend.OutputPath = out
- g := NewGenerator(cfg)
- if err := g.WriteFile(out, 20*time.Millisecond); err != nil {
- t.Fatalf("WriteFile failed: %v", err)
- }
- info, err := os.Stat(out)
- if err != nil {
- t.Fatalf("expected output file: %v", err)
- }
- if info.Size() == 0 {
- t.Fatal("expected non-empty file")
- }
- }
-
- func TestSummaryUsesToneFallback(t *testing.T) {
- cfg := cfgpkg.Default()
- cfg.Audio.InputPath = ""
- g := NewGenerator(cfg)
- summary := g.Summary(10 * time.Millisecond)
- if !strings.Contains(summary, "source=tones") {
- t.Fatalf("unexpected summary: %s", summary)
- }
- }
|