Browse files

add better tests around the bounds of the problem

  • Loading branch information...
1 parent 5fa6d7b commit 1beaeb69c404d51b468b845995652c1fdee2f928 @jmoiron jmoiron committed Dec 6, 2011
Showing with 13 additions and 4 deletions.
  1. +13 −4 python/tests.py
View
17 python/tests.py
@@ -590,10 +590,19 @@ class Nested:
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):
input = "X.Y"

0 comments on commit 1beaeb6

Please sign in to comment.