Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

50 wiersze
1.2KB

  1. package offline
  2. import (
  3. "os"
  4. "path/filepath"
  5. "strings"
  6. "testing"
  7. "time"
  8. cfgpkg "github.com/jan/fm-rds-tx/internal/config"
  9. )
  10. func TestGenerateFrame(t *testing.T) {
  11. g := NewGenerator(cfgpkg.Default())
  12. frame := g.GenerateFrame(50 * time.Millisecond)
  13. if frame == nil {
  14. t.Fatal("expected frame")
  15. }
  16. if len(frame.Samples) == 0 {
  17. t.Fatal("expected samples")
  18. }
  19. }
  20. func TestWriteFile(t *testing.T) {
  21. cfg := cfgpkg.Default()
  22. out := filepath.Join(t.TempDir(), "test.iqf32")
  23. cfg.Backend.OutputPath = out
  24. g := NewGenerator(cfg)
  25. if err := g.WriteFile(out, 20*time.Millisecond); err != nil {
  26. t.Fatalf("WriteFile failed: %v", err)
  27. }
  28. info, err := os.Stat(out)
  29. if err != nil {
  30. t.Fatalf("expected output file: %v", err)
  31. }
  32. if info.Size() == 0 {
  33. t.Fatal("expected non-empty file")
  34. }
  35. }
  36. func TestSummaryUsesToneFallback(t *testing.T) {
  37. cfg := cfgpkg.Default()
  38. cfg.Audio.InputPath = ""
  39. g := NewGenerator(cfg)
  40. summary := g.Summary(10 * time.Millisecond)
  41. if !strings.Contains(summary, "source=tones") {
  42. t.Fatalf("unexpected summary: %s", summary)
  43. }
  44. }