]> granicus.if.org Git - python/commitdiff
test_decimal: add __sizeof__() tests for code coverage.
authorStefan Krah <skrah@bytereef.org>
Wed, 29 May 2013 16:50:06 +0000 (18:50 +0200)
committerStefan Krah <skrah@bytereef.org>
Wed, 29 May 2013 16:50:06 +0000 (18:50 +0200)
Lib/test/test_decimal.py

index 7dd287e40ddc1ab9a9297566691d0fcbfa8e54a5..ae368930fec3a9b6ce53851e75a70e4c96e60297 100644 (file)
@@ -5372,6 +5372,19 @@ class CWhitebox(unittest.TestCase):
             x = (1, (0, 1), "N")
             self.assertEqual(str(Decimal(x)), '-sNaN1')
 
+    def test_sizeof(self):
+        Decimal = C.Decimal
+        HAVE_CONFIG_64 = (C.MAX_PREC > 425000000)
+
+        self.assertGreater(Decimal(0).__sizeof__(), 0)
+        if HAVE_CONFIG_64:
+            x = Decimal(10**(19*24)).__sizeof__()
+            y = Decimal(10**(19*25)).__sizeof__()
+            self.assertEqual(y, x+8)
+        else:
+            x = Decimal(10**(9*24)).__sizeof__()
+            y = Decimal(10**(9*25)).__sizeof__()
+            self.assertEqual(y, x+4)
 
 all_tests = [
   CExplicitConstructionTest, PyExplicitConstructionTest,