-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors_location_test.go
36 lines (26 loc) · 1.38 KB
/
errors_location_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
package errors
import (
"testing"
"github.com/stretchr/testify/assert"
"tlog.app/go/loc"
)
func TestDepthCaller(t *testing.T) {
assert.Equal(t, "errors_location_test.go:11", NewDepth(0, "msg").(Callerer).Caller().String())
assert.Equal(t, "errors_location_test.go:12", NewCaller(loc.Caller(0), "msg").(Callerer).Caller().String())
err := New("inner")
assert.Equal(t, "errors_location_test.go:16", WrapDepth(err, 0, "msg").(Callerer).Caller().String())
assert.Equal(t, "errors_location_test.go:17", WrapCaller(err, loc.Caller(0), "msg").(Callerer).Caller().String())
}
func TestStackCallers(t *testing.T) {
testStackCallers(t)
}
func testStackCallers(t *testing.T) {
assert.Equal(t, "errors_location_test.go:25", NewStack(0, 2, "msg").(Callerer).Caller().String())
assert.Equal(t, "errors_location_test.go:26", NewCallers(loc.Callers(0, 2), "msg").(Callerer).Caller().String())
err := New("inner")
assert.Equal(t, "errors_location_test.go:30", WrapStack(err, 0, 2, "msg").(Callerer).Caller().String())
assert.Equal(t, "errors_location_test.go:31", WrapCallers(err, loc.Callers(0, 2), "msg").(Callerer).Caller().String())
assert.Equal(t, PC(0), NewCallers(PCs{}, "msg").(Callerer).Caller())
assert.Equal(t, "errors_location_test.go:34", NewStack(0, 1, "msg").(Callerer).Caller().String())
assert.Equal(t, "errors_location_test.go:35", NewStack(0, 1, "msg").(Callerser).Callers().String())
}