Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

43 řádky
1016B

  1. package decoder
  2. import (
  3. "context"
  4. "io"
  5. "testing"
  6. "github.com/jan/fm-rds-tx/internal/ingest"
  7. )
  8. type fakeDecoder struct{ name string }
  9. func (d *fakeDecoder) Name() string { return d.name }
  10. func (d *fakeDecoder) DecodeStream(_ context.Context, _ io.Reader, _ StreamMeta, _ func(ingest.PCMChunk) error) error {
  11. return nil
  12. }
  13. func TestRegistrySelectByContentType(t *testing.T) {
  14. r := NewRegistry()
  15. r.Register("mp3", func() Decoder { return &fakeDecoder{name: "mp3"} })
  16. r.Register("oggvorbis", func() Decoder { return &fakeDecoder{name: "ogg"} })
  17. r.Register("aac", func() Decoder { return &fakeDecoder{name: "aac"} })
  18. tests := []struct {
  19. ct string
  20. want string
  21. }{
  22. {"audio/mpeg", "mp3"},
  23. {"application/ogg", "ogg"},
  24. {"audio/aac", "aac"},
  25. }
  26. for _, tt := range tests {
  27. dec, err := r.SelectByContentType(tt.ct)
  28. if err != nil {
  29. t.Fatalf("content-type %s: %v", tt.ct, err)
  30. }
  31. if dec.Name() != tt.want {
  32. t.Fatalf("content-type %s: got %s want %s", tt.ct, dec.Name(), tt.want)
  33. }
  34. }
  35. }