//go:build darwin && !cgo package platform import ( "testing" ) // TestGetCodecsForModel tests Apple silicon codec mapping and the Intel-Mac // trap: on amd64 the model string is a GPU name (e.g. "Intel Iris Plus // Graphics 655") and must not fall through to the Apple-silicon defaults. func TestGetCodecsForModel(t *testing.T) { m1 := []string{"hevc", "avc", "prores"} m2 := []string{"hevc", "avc", "vp9", "prores"} m3Plus := []string{"hevc", "avc", "vp9", "av1", "prores"} intelMac := []string{"avc", "hevc"} tests := []struct { name string model string want []string }{ {"M1", "apple m1", m1}, {"M2", "apple m2 pro", m2}, {"M3", "apple m3 max", m3Plus}, {"M4", "apple m4", m3Plus}, {"M5", "apple m5", m3Plus}, {"Intel Iris Plus", "intel iris plus graphics 655", intelMac}, {"Intel UHD", "intel uhd graphics 630", intelMac}, {"Intel with Apple chip substring", "intel(r) core(tm) i5 m1 lookalike", intelMac}, {"unknown fails conservatively", "some future chip", []string{"hevc", "avc"}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { codecs, err := getCodecsForModel(tt.model) if err != nil { t.Fatalf("getCodecsForModel(%q) error = %v", tt.model, err) } if !setsEqual(codecs, tt.want) { t.Errorf("getCodecsForModel(%q) = %v, want %v", tt.model, codecs, tt.want) } }) } }