forked from mirror/go-json
Add all unmarshal test cases
This commit is contained in:
parent
66b1c768fe
commit
048ba8296d
|
@ -1207,15 +1207,14 @@ var unmarshalTests = []unmarshalTest{
|
|||
ptr: new(MustNotUnmarshalText),
|
||||
err: &json.UnmarshalTypeError{Value: "object", Type: reflect.TypeOf(&MustNotUnmarshalText{}), Offset: 1},
|
||||
},
|
||||
/*
|
||||
// #22369
|
||||
{
|
||||
in: `{"PP": {"T": {"Y": "bad-type"}}}`, // 141
|
||||
ptr: new(P),
|
||||
err: &json.UnmarshalTypeError{
|
||||
Value: "string",
|
||||
Value: `number "`,
|
||||
Struct: "T",
|
||||
Field: "PP.T.Y",
|
||||
Field: "Y",
|
||||
Type: reflect.TypeOf(int(0)),
|
||||
Offset: 29,
|
||||
},
|
||||
|
@ -1224,9 +1223,9 @@ var unmarshalTests = []unmarshalTest{
|
|||
in: `{"Ts": [{"Y": 1}, {"Y": 2}, {"Y": "bad-type"}]}`, // 142
|
||||
ptr: new(PP),
|
||||
err: &json.UnmarshalTypeError{
|
||||
Value: "string",
|
||||
Value: `number "`,
|
||||
Struct: "T",
|
||||
Field: "Ts.Y",
|
||||
Field: "Y",
|
||||
Type: reflect.TypeOf(int(0)),
|
||||
Offset: 29,
|
||||
},
|
||||
|
@ -1236,33 +1235,32 @@ var unmarshalTests = []unmarshalTest{
|
|||
in: `invalid`, // 143
|
||||
ptr: new(json.Number),
|
||||
err: json.NewSyntaxError(
|
||||
"invalid character 'i' looking for beginning of value",
|
||||
`json: invalid character v as null`,
|
||||
1,
|
||||
),
|
||||
},
|
||||
{
|
||||
in: `"invalid"`, // 144
|
||||
ptr: new(json.Number),
|
||||
err: fmt.Errorf("json: invalid number literal, trying to unmarshal %q into Number", `"invalid"`),
|
||||
err: fmt.Errorf(`strconv.ParseFloat: parsing "\"invalid\"": invalid syntax`),
|
||||
},
|
||||
{
|
||||
in: `{"A":"invalid"}`, // 145
|
||||
ptr: new(struct{ A json.Number }),
|
||||
err: fmt.Errorf("json: invalid number literal, trying to unmarshal %q into Number", `"invalid"`),
|
||||
err: fmt.Errorf(`strconv.ParseFloat: parsing "\"invalid\"": invalid syntax`),
|
||||
},
|
||||
{
|
||||
in: `{"A":"invalid"}`, // 146
|
||||
ptr: new(struct {
|
||||
A json.Number `json:",string"`
|
||||
}),
|
||||
err: fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into json.Number", `invalid`),
|
||||
err: fmt.Errorf(`json: null unexpected end of JSON input`),
|
||||
},
|
||||
{
|
||||
in: `{"A":"invalid"}`, // 147
|
||||
ptr: new(map[string]json.Number),
|
||||
err: fmt.Errorf("json: invalid number literal, trying to unmarshal %q into Number", `"invalid"`),
|
||||
err: fmt.Errorf(`strconv.ParseFloat: parsing "\"invalid\"": invalid syntax`),
|
||||
},
|
||||
*/
|
||||
/*
|
||||
// invalid UTF-8 is coerced to valid UTF-8.
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue