-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_test.go
48 lines (35 loc) · 1015 Bytes
/
util_test.go
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
44
45
46
47
48
package elk_test
import (
"testing"
"github.com/studio-b12/elk"
"github.com/studio-b12/elk/internal/assert"
)
type stringError string
func (t stringError) Error() string { return string(t) }
type structError struct {
msg string
}
func (t structError) Error() string { return t.msg }
type refError struct{}
func (t *refError) Error() string { return "refError" }
func TestIsTypeOf(t *testing.T) {
assert.True(t,
elk.IsOfType[stringError](stringError("test")))
assert.True(t,
elk.IsOfType[structError](structError{"test"}))
assert.True(t,
elk.IsOfType[stringError](elk.InnerError{Inner: stringError("test")}))
assert.True(t,
elk.IsOfType[*refError](elk.InnerError{Inner: &refError{}}))
assert.False(t,
elk.IsOfType[structError](stringError("test")))
assert.False(t,
elk.IsOfType[stringError](structError{"test"}))
assert.False(t,
elk.IsOfType[structError](elk.InnerError{Inner: stringError("test")}))
}
type foo interface {
Foo()
}
type fooImpl struct{}
func (fooImpl) Foo() {}