[Python-checkins] r54210 - sandbox/trunk/pep3101/test_simpleformat.py
eric.smith
python-checkins at python.org
Wed Mar 7 16:46:37 CET 2007
Author: eric.smith
Date: Wed Mar 7 16:46:33 2007
New Revision: 54210
Modified:
sandbox/trunk/pep3101/test_simpleformat.py
Log:
Added more extensive binary formatting (':b') tests.
Modified: sandbox/trunk/pep3101/test_simpleformat.py
==============================================================================
--- sandbox/trunk/pep3101/test_simpleformat.py (original)
+++ sandbox/trunk/pep3101/test_simpleformat.py Wed Mar 7 16:46:33 2007
@@ -276,6 +276,16 @@
self.formatEqualsWithUnicode("-" + "1" * 100, "{0:b}", -(2**100 - 1))
self.formatEqualsWithUnicode("(" + "1" * 100 + ")", "{0:()b}", -(2**100 - 1))
self.formatEqualsWithUnicode("(" + " " * 98 + "1" * 100 + ")", "{0:=()200b}", -(2**100 - 1))
+ for n in range(1, 100):
+ # build an n bit integer, alternating ones and zeros
+ # as n gets large, these will become longs
+ s = "10" * (n / 2) + (n % 2 and "1" or "")
+ i = int(s, 2)
+ self.formatEquals(s, "{0:b}", i)
+
+ # make sure negative also works, hoping to catch an
+ # overflow off the end of the digits
+ self.formatEquals("(" + s + ")", "{0:()b}", -i)
def test_number_specifier(self):
def test(value):
More information about the Python-checkins
mailing list