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
9
9
import (
10
10
"bytes"
11
11
"encoding/json"
12
+ "errors"
12
13
"fmt"
13
14
"reflect"
14
15
"strconv"
@@ -456,13 +457,14 @@ func TestD_UnmarshalJSON(t *testing.T) {
456
457
want := json .Unmarshal ([]byte (tc .test ), & a )
457
458
var b D
458
459
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 ) {
461
462
w .Type = reflect .TypeOf (b )
462
463
require .IsType (t , want , got )
463
- g := got .(* json.UnmarshalTypeError )
464
+ g := new (json.UnmarshalTypeError )
465
+ assert .True (t , errors .As (got , & g ))
464
466
assert .Equal (t , w , g )
465
- default :
467
+ } else {
466
468
assert .Equal (t , want , got )
467
469
}
468
470
})
Original file line number Diff line number Diff line change @@ -369,7 +369,8 @@ func TestRegistry(t *testing.T) {
369
369
t .Parallel ()
370
370
371
371
wanterr := tc .wanterr
372
- if ene , ok := tc .wanterr .(errNoEncoder ); ok {
372
+ var ene errNoEncoder
373
+ if errors .As (tc .wanterr , & ene ) {
373
374
wanterr = errNoDecoder (ene )
374
375
}
375
376
You can’t perform that action at this time.
0 commit comments