57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package sdl
|
|
|
|
import (
|
|
"reflect"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestLibraryCandidatesForOS(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
goos string
|
|
want []string
|
|
}{
|
|
{
|
|
name: "Linux",
|
|
goos: "linux",
|
|
want: []string{"libSDL3.so.0", "libSDL3.so"},
|
|
},
|
|
{
|
|
name: "macOS",
|
|
goos: "darwin",
|
|
want: []string{"libSDL3.0.dylib", "libSDL3.dylib"},
|
|
},
|
|
{
|
|
name: "Windows",
|
|
goos: "windows",
|
|
want: []string{"SDL3.dll"},
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, err := libraryCandidatesForOS(tt.goos)
|
|
if err != nil {
|
|
t.Fatalf("libraryCandidatesForOS(%q): %v", tt.goos, err)
|
|
}
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
t.Fatalf("libraryCandidatesForOS(%q) = %v, want %v", tt.goos, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestLibraryCandidatesForOSRejectsUnsupportedOS(t *testing.T) {
|
|
got, err := libraryCandidatesForOS("plan9")
|
|
if err == nil {
|
|
t.Fatal("libraryCandidatesForOS(plan9) returned no error")
|
|
}
|
|
if got != nil {
|
|
t.Fatalf("libraryCandidatesForOS(plan9) = %v, want nil", got)
|
|
}
|
|
if !strings.Contains(err.Error(), `"plan9"`) {
|
|
t.Fatalf("error %q does not identify the unsupported OS", err)
|
|
}
|
|
}
|