MCPcopy Index your code
hub / github.com/chain/txvm / TestSub

Function TestSub

errors/errors_test.go:122–143  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

120}
121
122func TestSub(t *testing.T) {
123 x := errors.New("x")
124 y := errors.New("y")
125 cases := []struct{ new, old, want error }{
126 {nil, nil, nil},
127 {x, nil, nil},
128 {nil, Wrap(y), nil},
129 {Wrap(x), nil, nil},
130 {nil, y, nil},
131 {x, y, errors.New("y: x")},
132 {Wrap(x), y, errors.New("y: x")},
133 {x, Wrap(y), errors.New("y: x")},
134 {Wrap(x, "z"), Wrap(y), errors.New("y: z: x")},
135 }
136
137 for _, test := range cases {
138 got := Sub(test.new, test.old)
139 if !(got == nil && test.want == nil || got.Error() == test.want.Error()) {
140 t.Errorf("Sub(%#v, %#v) = %v, want %v", test.new, test.old, got, test.want)
141 }
142 }
143}

Callers

nothing calls this directly

Calls 3

WrapFunction · 0.85
SubFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected