You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-24 23:16:47 +02:00
fix negative number to uint
This commit is contained in:
@ -12,7 +12,7 @@ var intConvertMap = map[string]int{
|
||||
"321.1": 321,
|
||||
"-321.1": -321,
|
||||
`"1.1"`: 1,
|
||||
`"-1.1"`: -1,
|
||||
`"-321.1"`: -321,
|
||||
"0.0": 0,
|
||||
"0": 0,
|
||||
`"0"`: 0,
|
||||
@ -58,13 +58,15 @@ func Test_read_any_to_int(t *testing.T) {
|
||||
}
|
||||
|
||||
var uintConvertMap = map[string]int{
|
||||
|
||||
"321.1": 321,
|
||||
`"1.1"`: 1,
|
||||
`"-1.1"`: 1,
|
||||
`"-123.1"`: 123,
|
||||
"0.0": 0,
|
||||
"0": 0,
|
||||
`"0"`: 0,
|
||||
`"0.0"`: 0,
|
||||
`"00.0"`: 0,
|
||||
"true": 1,
|
||||
"false": 0,
|
||||
`"true"`: 0,
|
||||
@ -75,12 +77,13 @@ var uintConvertMap = map[string]int{
|
||||
`""`: 0,
|
||||
"+": 0,
|
||||
"-": 0,
|
||||
".": 0,
|
||||
"[]": 0,
|
||||
"[1,2]": 1,
|
||||
"{}": 0,
|
||||
// TODO need to solve
|
||||
//"-1.1": 1,
|
||||
//"-321.1": 321,
|
||||
"{1,2}": 0,
|
||||
"-1.1": 1,
|
||||
"-321.1": 321,
|
||||
}
|
||||
|
||||
func Test_read_any_to_uint(t *testing.T) {
|
||||
@ -98,7 +101,7 @@ func Test_read_any_to_uint(t *testing.T) {
|
||||
|
||||
for k, v := range uintConvertMap {
|
||||
any := Get([]byte(k))
|
||||
should.Equal(uint32(v), any.ToUint32(), fmt.Sprintf("origin val %v", k))
|
||||
should.Equal(uint(v), any.ToUint(), fmt.Sprintf("origin val %v", k))
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user