mirror of
https://github.com/ultrajson/ultrajson.git
synced 2024-11-24 05:12:02 +01:00
add better tests around the bounds of the problem
This commit is contained in:
parent
5fa6d7be25
commit
1beaeb69c4
@ -590,9 +590,18 @@ class UltraJSONTests(TestCase):
|
||||
|
||||
def test_decodeNumberWith32bitSignBit(self):
|
||||
"""Test that numbers that fit within 32 bits but would have the
|
||||
sign bit set (2**31 < x < 2**32) are decoded properly."""
|
||||
doc = '{"id": 3590016419}'
|
||||
self.assertEqual(ujson.decode(doc)['id'], 3590016419)
|
||||
sign bit set (2**31 <= x < 2**32) are decoded properly."""
|
||||
boundary1 = 2**31
|
||||
boundary2 = 2**32
|
||||
docs = (
|
||||
'{"id": 3590016419}',
|
||||
'{"id": %s}' % 2**31,
|
||||
'{"id": %s}' % 2**32,
|
||||
'{"id": %s}' % ((2**32)-1),
|
||||
)
|
||||
results = (3590016419, 2**31, 2**32, 2**32-1)
|
||||
for doc,result in zip(docs, results):
|
||||
self.assertEqual(ujson.decode(doc)['id'], result)
|
||||
|
||||
"""
|
||||
def test_decodeNumericIntFrcOverflow(self):
|
||||
|
Loading…
Reference in New Issue
Block a user