github.com/zerosnake0/jzon@v0.0.9-0.20230801092939-1b135cb83f7f/errors_test.go (about) 1 package jzon 2 3 import ( 4 "errors" 5 "reflect" 6 "testing" 7 8 "github.com/stretchr/testify/require" 9 ) 10 11 var errorsNewType = reflect.TypeOf(errors.New("")) 12 13 func checkError(t *testing.T, exp, got error) { 14 internalErr, ok := got.(*DecodeError) 15 if ok { 16 got = internalErr.reason 17 } 18 if reflect.TypeOf(exp) == errorsNewType { 19 require.Equalf(t, exp, got, "exp err:%v\ngot err:%v", exp, got) 20 } else { 21 require.IsTypef(t, exp, got, "exp err:%v\ngot err:%v", exp, got) 22 } 23 }