MCPcopy Create free account
hub / github.com/chain/Core / TestSub

Function TestSub

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

WrapFunction · 0.85
SubFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected