forked from gogpu/gogpu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
43 lines (38 loc) · 857 Bytes
/
Copy patherrors_test.go
File metadata and controls
43 lines (38 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package gogpu
import (
"errors"
"testing"
)
func TestErrorConstants(t *testing.T) {
tests := []struct {
err error
want string
}{
{ErrNotInitialized, "gogpu: not initialized"},
{ErrPlatformNotSupported, "gogpu: platform not supported"},
{ErrNoGPU, "gogpu: no suitable GPU found"},
{ErrSurfaceLost, "gogpu: surface lost"},
}
for _, tt := range tests {
t.Run(tt.want, func(t *testing.T) {
if tt.err.Error() != tt.want {
t.Errorf("error = %q, want %q", tt.err.Error(), tt.want)
}
})
}
}
func TestErrorsAreDistinct(t *testing.T) {
errs := []error{
ErrNotInitialized,
ErrPlatformNotSupported,
ErrNoGPU,
ErrSurfaceLost,
}
for i := 0; i < len(errs); i++ {
for j := i + 1; j < len(errs); j++ {
if errors.Is(errs[i], errs[j]) {
t.Errorf("errors should be distinct: %v == %v", errs[i], errs[j])
}
}
}
}