(t *testing.T)
| 1065 | } |
| 1066 | |
| 1067 | func TestDecode_NilInterfaceHook(t *testing.T) { |
| 1068 | t.Parallel() |
| 1069 | |
| 1070 | input := map[string]interface{}{ |
| 1071 | "w": "", |
| 1072 | } |
| 1073 | |
| 1074 | decodeHook := func(f, t reflect.Type, v interface{}) (interface{}, error) { |
| 1075 | if t.String() == "io.Writer" { |
| 1076 | return nil, nil |
| 1077 | } |
| 1078 | |
| 1079 | return v, nil |
| 1080 | } |
| 1081 | |
| 1082 | var result NilInterface |
| 1083 | config := &DecoderConfig{ |
| 1084 | DecodeHook: decodeHook, |
| 1085 | Result: &result, |
| 1086 | } |
| 1087 | |
| 1088 | decoder, err := NewDecoder(config) |
| 1089 | if err != nil { |
| 1090 | t.Fatalf("err: %s", err) |
| 1091 | } |
| 1092 | |
| 1093 | err = decoder.Decode(input) |
| 1094 | if err != nil { |
| 1095 | t.Fatalf("got an err: %s", err) |
| 1096 | } |
| 1097 | |
| 1098 | if result.W != nil { |
| 1099 | t.Errorf("W should be nil: %#v", result.W) |
| 1100 | } |
| 1101 | } |
| 1102 | |
| 1103 | func TestDecode_NilPointerHook(t *testing.T) { |
| 1104 | t.Parallel() |
nothing calls this directly
no test coverage detected