summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2013-11-26 16:19:38 +0000
committerMark Dickinson <dickinsm@gmail.com>2013-11-26 16:19:38 +0000
commit1df88677e96f258a917b1cec0940ea98aeccaa72 (patch)
tree34a4cf3e6afda9326dfda36395f9431128ca2f7a /Lib/test
parent6bfe39272e6f06c1bf72a0b6572976d631faea1e (diff)
parentf45bbb62110a7bbcbbf45c1a52be6de7b791b189 (diff)
downloadcpython-git-1df88677e96f258a917b1cec0940ea98aeccaa72.tar.gz
Issue #19638: Merge from 3.3
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_strtod.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_strtod.py b/Lib/test/test_strtod.py
index 7a42a893b1..eee8a23228 100644
--- a/Lib/test/test_strtod.py
+++ b/Lib/test/test_strtod.py
@@ -248,6 +248,37 @@ class StrtodTests(unittest.TestCase):
else:
assert False, "expected ValueError"
+ @test.support.bigmemtest(size=5 * test.support._1G, memuse=1, dry_run=False)
+ def test_oversized_digit_strings(self, maxsize):
+ # Input string whose length doesn't fit in an INT.
+ s = "1." + "1" * int(2.2e9)
+ with self.assertRaises(ValueError):
+ float(s)
+ del s
+
+ s = "0." + "0" * int(2.2e9) + "1"
+ with self.assertRaises(ValueError):
+ float(s)
+ del s
+
+ def test_large_exponents(self):
+ # Verify that the clipping of the exponent in strtod doesn't affect the
+ # output values.
+ def positive_exp(n):
+ """ Long string with value 1.0 and exponent n"""
+ return '0.{}1e+{}'.format('0'*(n-1), n)
+
+ def negative_exp(n):
+ """ Long string with value 1.0 and exponent -n"""
+ return '1{}e-{}'.format('0'*n, n)
+
+ self.assertEqual(float(positive_exp(10000)), 1.0)
+ self.assertEqual(float(positive_exp(20000)), 1.0)
+ self.assertEqual(float(positive_exp(30000)), 1.0)
+ self.assertEqual(float(negative_exp(10000)), 1.0)
+ self.assertEqual(float(negative_exp(20000)), 1.0)
+ self.assertEqual(float(negative_exp(30000)), 1.0)
+
def test_particular(self):
# inputs that produced crashes or incorrectly rounded results with
# previous versions of dtoa.c, for various reasons