File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import (
2323 "io"
2424 "math"
2525 "reflect"
26+ "strconv"
2627 "strings"
2728 "testing"
2829 "time"
@@ -38,6 +39,16 @@ var negativeZero = math.Copysign(0.0, -1.0)
3839
3940var unmarshalIntTest = 123
4041
42+ // archSafeInt returns an int64 representation of v that is safe for the current architecture.
43+ func archSafeInt (v int64 ) any {
44+ if strconv .IntSize == 64 || math .MinInt32 < v && v < math .MaxInt32 {
45+ return int (v ) // int is safe
46+ }
47+
48+ // on 32-bit systems, and v is overflows int, we need to return an int64
49+ return int64 (v )
50+ }
51+
4152var unmarshalTests = []struct {
4253 data string
4354 value any
@@ -244,7 +255,7 @@ var unmarshalTests = []struct {
244255 },
245256 {
246257 "bin: -0b1000000000000000000000000000000000000000000000000000000000000000" ,
247- map [string ]int64 {"bin" : - 9223372036854775808 },
258+ map [string ]any {"bin" : archSafeInt ( - 9223372036854775808 ) },
248259 },
249260 {
250261 "decimal: +685_230" ,
You can’t perform that action at this time.
0 commit comments