MCPcopy Index your code
hub / github.com/go-errors/errors / TestNew

Function TestNew

error_test.go:107–131  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func TestNew(t *testing.T) {
108
109 err := New("foo")
110
111 if err.Error() != "foo" {
112 t.Errorf("Wrong message")
113 }
114
115 err = New(fmt.Errorf("foo"))
116
117 if err.Error() != "foo" {
118 t.Errorf("Wrong message")
119 }
120
121 bs := [][]uintptr{New("foo").stack, callers()}
122
123 if err := compareStacks(bs[0], bs[1]); err != nil {
124 t.Errorf("Stack didn't match")
125 t.Errorf(err.Error())
126 }
127
128 if err.ErrorStack() != err.TypeName()+" "+err.Error()+"\n"+string(err.Stack()) {
129 t.Errorf("ErrorStack is in the wrong format")
130 }
131}
132
133// This test should work for any go version
134func TestIs(t *testing.T) {

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
callersFunction · 0.85
compareStacksFunction · 0.85
ErrorStackMethod · 0.80
TypeNameMethod · 0.80
StackMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…