diff options
Diffstat (limited to 'libgo/go/encoding/json/encode_test.go')
-rw-r--r-- | libgo/go/encoding/json/encode_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libgo/go/encoding/json/encode_test.go b/libgo/go/encoding/json/encode_test.go index 9366589f252..0e39559a463 100644 --- a/libgo/go/encoding/json/encode_test.go +++ b/libgo/go/encoding/json/encode_test.go @@ -6,6 +6,7 @@ package json import ( "bytes" + "math" "reflect" "testing" ) @@ -107,3 +108,21 @@ func TestEncodeRenamedByteSlice(t *testing.T) { t.Errorf(" got %s want %s", result, expect) } } + +var unsupportedValues = []interface{}{ + math.NaN(), + math.Inf(-1), + math.Inf(1), +} + +func TestUnsupportedValues(t *testing.T) { + for _, v := range unsupportedValues { + if _, err := Marshal(v); err != nil { + if _, ok := err.(*UnsupportedValueError); !ok { + t.Errorf("for %v, got %T want UnsupportedValueError", v, err) + } + } else { + t.Errorf("for %v, expected error", v) + } + } +} |