package player_test import ( "testing" "git.maze.io/go/bragi/player" "periph.io/x/conn/v3/physic" ) 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) }) } }