aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/decode_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/json/decode_test.go')
-rw-r--r--src/encoding/json/decode_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/encoding/json/decode_test.go b/src/encoding/json/decode_test.go
index 0df31c82c8..d12495f90b 100644
--- a/src/encoding/json/decode_test.go
+++ b/src/encoding/json/decode_test.go
@@ -416,6 +416,8 @@ type DoublePtr struct {
J **int
}
+type NestedUnamed struct{ F struct{ V int } }
+
var unmarshalTests = []struct {
CaseName
in string
@@ -1213,6 +1215,28 @@ var unmarshalTests = []struct {
F string `json:"-,omitempty"`
}{"hello"},
},
+
+ {
+ CaseName: Name("ErrorForNestedUnamed"),
+ in: `{"F":{"V":"s"}}`,
+ ptr: new(NestedUnamed),
+ out: NestedUnamed{},
+ err: &UnmarshalTypeError{Value: "string", Type: reflect.TypeFor[int](), Offset: 13, Field: "F.V"},
+ },
+ {
+ CaseName: Name("ErrorInterface"),
+ in: `1`,
+ ptr: new(error),
+ out: error(nil),
+ err: &UnmarshalTypeError{Value: "number", Type: reflect.TypeFor[error](), Offset: 1},
+ },
+ {
+ CaseName: Name("ErrorChan"),
+ in: `1`,
+ ptr: new(chan int),
+ out: (chan int)(nil),
+ err: &UnmarshalTypeError{Value: "number", Type: reflect.TypeFor[chan int](), Offset: 1},
+ },
}
func TestMarshal(t *testing.T) {