File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package errors
22
33import (
44 "errors"
5+ stdlib_errors "errors"
56 "fmt"
67 "io"
78 "reflect"
@@ -249,3 +250,25 @@ func TestErrorEquality(t *testing.T) {
249250 }
250251 }
251252}
253+
254+ func TestIs (t * testing.T ) {
255+ sentinelError := stdlib_errors .New ("sentinel error" )
256+ wrap := Wrap (sentinelError , "wrap error" )
257+ if ! Is (wrap , sentinelError ) {
258+ t .Errorf ("Expected that '%v' error and the '%v' error should be of the same type" , sentinelError , wrap )
259+ }
260+ }
261+
262+ func TestAs (t * testing.T ) {
263+ type myError struct {
264+ error
265+ }
266+ err := & myError {stdlib_errors .New ("error" )}
267+ wrap := Wrap (err , "wrap error" )
268+
269+ var tt * myError
270+ if ! As (wrap , & tt ) {
271+ t .Errorf ("Expected that '%v' error and the '%v' error should be of the same type" , err , wrap )
272+ }
273+
274+ }
You can’t perform that action at this time.
0 commit comments