Files
beatglow/player/player_test.go
2026-10-29 17:29:41 +01:00

38 lines
992 B
Go

package player_test
import (
"testing"
"periph.io/x/conn/v3/physic"
"github.com/BeatGlow/beatglow/player"
)
func TestParseMPDAudioFormat(t *testing.T) {
testCases := []struct {
Input string
Format player.AudioFormat
}{
{"44100:16:2", player.AudioFormat{SampleRate: 44100 * physic.Hertz, Channels: 2, Bits: 16}},
{"22050:8:1", player.AudioFormat{SampleRate: 22050 * physic.Hertz, Channels: 1, Bits: 8}},
}
for _, test := range testCases {
t.Run(test.Input, func(it *testing.T) {
f, err := player.ParseMPDAudioFormat(test.Input)
if err != nil {
it.Fatal(err)
}
if f.SampleRate != test.Format.SampleRate {
it.Errorf("expected sample rate %s, got %s", test.Format.SampleRate, f.SampleRate)
}
if f.Channels != test.Format.Channels {
it.Errorf("expected %d channels, got %d", test.Format.Channels, f.Channels)
}
if f.Bits != test.Format.Bits {
it.Errorf("expected %d bits, got %d", test.Format.Bits, f.Bits)
}
it.Log(f)
})
}
}