diff options
Diffstat (limited to 'libgo/go/json/decode_test.go')
-rw-r--r-- | libgo/go/json/decode_test.go | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/libgo/go/json/decode_test.go b/libgo/go/json/decode_test.go index b805d3d82f7..9cb27af412a 100644 --- a/libgo/go/json/decode_test.go +++ b/libgo/go/json/decode_test.go @@ -52,7 +52,7 @@ var unmarshalTests = []unmarshalTest{ // basic types {`true`, new(bool), true, nil}, {`1`, new(int), 1, nil}, - {`1.2`, new(float), 1.2, nil}, + {`1.2`, new(float64), 1.2, nil}, {`-5`, new(int16), int16(-5), nil}, {`"a\u1234"`, new(string), "a\u1234", nil}, {`"http:\/\/"`, new(string), "http://", nil}, @@ -102,6 +102,20 @@ func TestMarshal(t *testing.T) { } } +func TestMarshalBadUTF8(t *testing.T) { + s := "hello\xffworld" + b, err := Marshal(s) + if err == nil { + t.Fatal("Marshal bad UTF8: no error") + } + if len(b) != 0 { + t.Fatal("Marshal returned data") + } + if _, ok := err.(*InvalidUTF8Error); !ok { + t.Fatalf("Marshal did not return InvalidUTF8Error: %T %v", err, err) + } +} + func TestUnmarshal(t *testing.T) { var scan scanner for i, tt := range unmarshalTests { @@ -206,7 +220,6 @@ type All struct { Uint32 uint32 Uint64 uint64 Uintptr uintptr - Float float Float32 float32 Float64 float64 @@ -224,7 +237,6 @@ type All struct { PUint32 *uint32 PUint64 *uint64 PUintptr *uintptr - PFloat *float PFloat32 *float32 PFloat64 *float64 @@ -256,6 +268,8 @@ type All struct { Interface interface{} PInterface *interface{} + + unexported int } type Small struct { @@ -275,7 +289,6 @@ var allValue = All{ Uint32: 10, Uint64: 11, Uintptr: 12, - Float: 13.1, Float32: 14.1, Float64: 15.1, Foo: "foo", @@ -296,7 +309,7 @@ var allValue = All{ ByteSlice: []byte{27, 28, 29}, Small: Small{Tag: "tag30"}, PSmall: &Small{Tag: "tag31"}, - Interface: float64(5.2), + Interface: 5.2, } var pallValue = All{ @@ -312,7 +325,6 @@ var pallValue = All{ PUint32: &allValue.Uint32, PUint64: &allValue.Uint64, PUintptr: &allValue.Uintptr, - PFloat: &allValue.Float, PFloat32: &allValue.Float32, PFloat64: &allValue.Float64, PString: &allValue.String, @@ -337,7 +349,6 @@ var allValueIndent = `{ "Uint32": 10, "Uint64": 11, "Uintptr": 12, - "Float": 13.1, "Float32": 14.1, "Float64": 15.1, "bar": "foo", @@ -353,7 +364,6 @@ var allValueIndent = `{ "PUint32": null, "PUint64": null, "PUintptr": null, - "PFloat": null, "PFloat32": null, "PFloat64": null, "String": "16", @@ -433,7 +443,6 @@ var pallValueIndent = `{ "Uint32": 0, "Uint64": 0, "Uintptr": 0, - "Float": 0, "Float32": 0, "Float64": 0, "bar": "", @@ -449,7 +458,6 @@ var pallValueIndent = `{ "PUint32": 10, "PUint64": 11, "PUintptr": 12, - "PFloat": 13.1, "PFloat32": 14.1, "PFloat64": 15.1, "String": "", |