File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ package bson
99import (
1010 "bytes"
1111 "encoding/json"
12+ "errors"
1213 "fmt"
1314 "reflect"
1415 "strconv"
@@ -456,13 +457,14 @@ func TestD_UnmarshalJSON(t *testing.T) {
456457 want := json .Unmarshal ([]byte (tc .test ), & a )
457458 var b D
458459 got := json .Unmarshal ([]byte (tc .test ), & b )
459- switch w := want .( type ) {
460- case * json. UnmarshalTypeError :
460+ w := new (json. UnmarshalTypeError )
461+ if errors . As ( want , & w ) {
461462 w .Type = reflect .TypeOf (b )
462463 require .IsType (t , want , got )
463- g := got .(* json.UnmarshalTypeError )
464+ g := new (json.UnmarshalTypeError )
465+ assert .True (t , errors .As (got , & g ))
464466 assert .Equal (t , w , g )
465- default :
467+ } else {
466468 assert .Equal (t , want , got )
467469 }
468470 })
Original file line number Diff line number Diff line change @@ -369,7 +369,8 @@ func TestRegistry(t *testing.T) {
369369 t .Parallel ()
370370
371371 wanterr := tc .wanterr
372- if ene , ok := tc .wanterr .(errNoEncoder ); ok {
372+ var ene errNoEncoder
373+ if errors .As (tc .wanterr , & ene ) {
373374 wanterr = errNoDecoder (ene )
374375 }
375376
You can’t perform that action at this time.
0 commit comments