Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 line
807B

  1. package dryrun
  2. import (
  3. "os"
  4. "path/filepath"
  5. "testing"
  6. cfgpkg "github.com/jan/fm-rds-tx/internal/config"
  7. )
  8. func TestGenerate(t *testing.T) {
  9. cfg := cfgpkg.Default()
  10. frame := Generate(cfg)
  11. if frame.Mode != "dry-run" { t.Fatalf("mode: %s", frame.Mode) }
  12. if len(frame.PreviewSamples) != 16 { t.Fatal("preview length") }
  13. if frame.Source != "tones" { t.Fatal("source") }
  14. if frame.PreEmphasisTauUS != 50 { t.Fatal("preemph") }
  15. if !frame.FMModulation { t.Fatal("fm mod") }
  16. if frame.DeviceRate != float64(cfg.FM.CompositeRateHz) { t.Fatal("device rate") }
  17. }
  18. func TestWriteJSONFile(t *testing.T) {
  19. dir := t.TempDir()
  20. out := filepath.Join(dir, "frame.json")
  21. if err := WriteJSON(out, Generate(cfgpkg.Default())); err != nil { t.Fatal(err) }
  22. if _, err := os.Stat(out); err != nil { t.Fatal(err) }
  23. }