| 304 | } |
| 305 | |
| 306 | func TestPlus53BitInts(t *testing.T) { |
| 307 | json := `{"IdentityData":{"GameInstanceId":634866135153775564}}` |
| 308 | value := Get(json, "IdentityData.GameInstanceId") |
| 309 | assert(t, value.Uint() == 634866135153775564) |
| 310 | assert(t, value.Int() == 634866135153775564) |
| 311 | assert(t, value.Float() == 634866135153775616) |
| 312 | |
| 313 | json = `{"IdentityData":{"GameInstanceId":634866135153775564.88172}}` |
| 314 | value = Get(json, "IdentityData.GameInstanceId") |
| 315 | assert(t, value.Uint() == 634866135153775616) |
| 316 | assert(t, value.Int() == 634866135153775616) |
| 317 | assert(t, value.Float() == 634866135153775616.88172) |
| 318 | |
| 319 | json = `{ |
| 320 | "min_uint64": 0, |
| 321 | "max_uint64": 18446744073709551615, |
| 322 | "overflow_uint64": 18446744073709551616, |
| 323 | "min_int64": -9223372036854775808, |
| 324 | "max_int64": 9223372036854775807, |
| 325 | "overflow_int64": 9223372036854775808, |
| 326 | "min_uint53": 0, |
| 327 | "max_uint53": 4503599627370495, |
| 328 | "overflow_uint53": 4503599627370496, |
| 329 | "min_int53": -2251799813685248, |
| 330 | "max_int53": 2251799813685247, |
| 331 | "overflow_int53": 2251799813685248 |
| 332 | }` |
| 333 | |
| 334 | assert(t, Get(json, "min_uint53").Uint() == 0) |
| 335 | assert(t, Get(json, "max_uint53").Uint() == 4503599627370495) |
| 336 | assert(t, Get(json, "overflow_uint53").Int() == 4503599627370496) |
| 337 | assert(t, Get(json, "min_int53").Int() == -2251799813685248) |
| 338 | assert(t, Get(json, "max_int53").Int() == 2251799813685247) |
| 339 | assert(t, Get(json, "overflow_int53").Int() == 2251799813685248) |
| 340 | assert(t, Get(json, "min_uint64").Uint() == 0) |
| 341 | assert(t, Get(json, "max_uint64").Uint() == 18446744073709551615) |
| 342 | // this next value overflows the max uint64 by one which will just |
| 343 | // flip the number to zero |
| 344 | assert(t, Get(json, "overflow_uint64").Int() == 0) |
| 345 | assert(t, Get(json, "min_int64").Int() == -9223372036854775808) |
| 346 | assert(t, Get(json, "max_int64").Int() == 9223372036854775807) |
| 347 | // this next value overflows the max int64 by one which will just |
| 348 | // flip the number to the negative sign. |
| 349 | assert(t, Get(json, "overflow_int64").Int() == -9223372036854775808) |
| 350 | } |
| 351 | func TestIssue38(t *testing.T) { |
| 352 | // These should not fail, even though the unicode is invalid. |
| 353 | Get(`["S3O PEDRO DO BUTI\udf93"]`, "0") |