-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgt.go
41 lines (35 loc) · 862 Bytes
/
gt.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
package gt
import (
"fmt"
"reflect"
)
var (
DefaultDiffFunc diffFunc = func(want, got any) string {
if !reflect.DeepEqual(want, got) {
return fmt.Sprintf("want: %#+v\ngot: %#+v", want, got)
}
return ""
}
DefaultFailFunc = func(t testingT) {
t.FailNow()
}
DefaultFailHookFunc = func() {}
)
type testingT interface {
Fail()
FailNow()
Helper()
Log(...any)
}
func ErrorIs(t testingT, prefix string, err, target error, opts ...option) bool {
t.Helper()
return newConfig(opts...).ErrorIs(t, prefix, err, target, opts...)
}
func Equal(t testingT, prefix string, want, got any, opts ...option) bool {
t.Helper()
return newConfig(opts...).Equal(t, prefix, want, got, opts...)
}
func NotEqual(t testingT, prefix string, want, got any, opts ...option) bool {
t.Helper()
return newConfig(opts...).NotEqual(t, prefix, want, got, opts...)
}