Checkpoint

This commit is contained in:
maze authored and maze committed 2026-10-29 17:28:51 +01:00
1 parent 7b6db17870
commit 0295eb1ad2
125 files changed
+59376

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
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)
})
}
}