|
|
|
@ -976,6 +976,19 @@ func TestUnmarshalFloat32WithOverflow(t *testing.T) {
|
|
|
|
|
assert.Error(t, UnmarshalKey(m, &in))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("float32 from string less than float32", func(t *testing.T) {
|
|
|
|
|
type inner struct {
|
|
|
|
|
Value float32 `key:"float, string"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m := map[string]any{
|
|
|
|
|
"float": "-1.79769313486231570814527423731704356798070e+300", // overflow
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var in inner
|
|
|
|
|
assert.Error(t, UnmarshalKey(m, &in))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("float32 from json.Number greater than float64", func(t *testing.T) {
|
|
|
|
|
type inner struct {
|
|
|
|
|
Value float32 `key:"float"`
|
|
|
|
@ -1001,6 +1014,19 @@ func TestUnmarshalFloat32WithOverflow(t *testing.T) {
|
|
|
|
|
var in inner
|
|
|
|
|
assert.Error(t, UnmarshalKey(m, &in))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("float32 from json number less than float32", func(t *testing.T) {
|
|
|
|
|
type inner struct {
|
|
|
|
|
Value float32 `key:"float"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m := map[string]any{
|
|
|
|
|
"float": json.Number("-1.79769313486231570814527423731704356798070e+300"), // overflow
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var in inner
|
|
|
|
|
assert.Error(t, UnmarshalKey(m, &in))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestUnmarshalFloat64WithOverflow(t *testing.T) {
|
|
|
|
|