package page import ( "testing" "rhemawavetech.com/rhemawave/internal/mixer" ) func TestCurrentDeviceIndex(t *testing.T) { devices := []mixer.Device{ {Name: "Built-in Audio Analog Stereo", Label: "Internal Speakers"}, {Name: "Built-in Audio Digital Stereo (HDMI)", Label: "HDMI | Monitor | TV"}, } tests := []struct { name string devices []mixer.Device currentName string want int }{ {"empty list, default device", nil, "", 0}, {"empty list, named device", nil, "USB Audio", -1}, {"default device", devices, "", 0}, {"exact first device match", devices, "Built-in Audio Analog Stereo", 1}, {"exact second device match", devices, "Built-in Audio Digital Stereo (HDMI)", 2}, {"no match", devices, "USB Audio", -1}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := currentDeviceIndex(tt.devices, tt.currentName); got != tt.want { t.Errorf("currentDeviceIndex(%v, %q) = %d, want %d", tt.devices, tt.currentName, got, tt.want) } }) } }