@@ -114,6 +114,7 @@ def test_common_format(self):
114114 testcommon ("%o" , 100000000000 , "1351035564000" )
115115 testcommon ("%d" , 10 , "10" )
116116 testcommon ("%d" , 100000000000 , "100000000000" )
117+
117118 big = 123456789012345678901234567890
118119 testcommon ("%d" , big , "123456789012345678901234567890" )
119120 testcommon ("%d" , - big , "-123456789012345678901234567890" )
@@ -133,6 +134,7 @@ def test_common_format(self):
133134 testcommon ("%.31d" , big , "0123456789012345678901234567890" )
134135 testcommon ("%32.31d" , big , " 0123456789012345678901234567890" )
135136 testcommon ("%d" , float (big ), "123456________________________" , 6 )
137+
136138 big = 0x1234567890abcdef12345 # 21 hex digits
137139 testcommon ("%x" , big , "1234567890abcdef12345" )
138140 testcommon ("%x" , - big , "-1234567890abcdef12345" )
@@ -156,19 +158,26 @@ def test_common_format(self):
156158 testcommon ("%#X" , big , "0X1234567890ABCDEF12345" )
157159 testcommon ("%#x" , big , "0x1234567890abcdef12345" )
158160 testcommon ("%#x" , - big , "-0x1234567890abcdef12345" )
161+ testcommon ("%#27x" , big , " 0x1234567890abcdef12345" )
162+ testcommon ("%#-27x" , big , "0x1234567890abcdef12345 " )
163+ testcommon ("%#027x" , big , "0x00001234567890abcdef12345" )
164+ testcommon ("%#.23x" , big , "0x001234567890abcdef12345" )
159165 testcommon ("%#.23x" , - big , "-0x001234567890abcdef12345" )
166+ testcommon ("%#27.23x" , big , " 0x001234567890abcdef12345" )
167+ testcommon ("%#-27.23x" , big , "0x001234567890abcdef12345 " )
168+ testcommon ("%#027.23x" , big , "0x00001234567890abcdef12345" )
160169 testcommon ("%#+.23x" , big , "+0x001234567890abcdef12345" )
161170 testcommon ("%# .23x" , big , " 0x001234567890abcdef12345" )
162171 testcommon ("%#+.23X" , big , "+0X001234567890ABCDEF12345" )
163- testcommon ("%#-+.23X" , big , "+0X001234567890ABCDEF12345" )
164- testcommon ("%#-+26.23X" , big , "+0X001234567890ABCDEF12345" )
165- testcommon ("%#-+27.23X" , big , "+0X001234567890ABCDEF12345 " )
166- testcommon ("%#+27.23X" , big , " +0X001234567890ABCDEF12345" )
167172 # next one gets two leading zeroes from precision, and another from the
168173 # 0 flag and the width
169174 testcommon ("%#+027.23X" , big , "+0X0001234567890ABCDEF12345" )
175+ testcommon ("%# 027.23X" , big , " 0X0001234567890ABCDEF12345" )
170176 # same, except no 0 flag
171177 testcommon ("%#+27.23X" , big , " +0X001234567890ABCDEF12345" )
178+ testcommon ("%#-+27.23x" , big , "+0x001234567890abcdef12345 " )
179+ testcommon ("%#- 27.23x" , big , " 0x001234567890abcdef12345 " )
180+
172181 big = 0o12345670123456701234567012345670 # 32 octal digits
173182 testcommon ("%o" , big , "12345670123456701234567012345670" )
174183 testcommon ("%o" , - big , "-12345670123456701234567012345670" )
@@ -191,13 +200,21 @@ def test_common_format(self):
191200 testcommon ("%o" , big , "12345670123456701234567012345670" )
192201 testcommon ("%#o" , big , "0o12345670123456701234567012345670" )
193202 testcommon ("%#o" , - big , "-0o12345670123456701234567012345670" )
203+ testcommon ("%#38o" , big , " 0o12345670123456701234567012345670" )
204+ testcommon ("%#-38o" , big , "0o12345670123456701234567012345670 " )
205+ testcommon ("%#038o" , big , "0o000012345670123456701234567012345670" )
206+ testcommon ("%#.34o" , big , "0o0012345670123456701234567012345670" )
194207 testcommon ("%#.34o" , - big , "-0o0012345670123456701234567012345670" )
208+ testcommon ("%#38.34o" , big , " 0o0012345670123456701234567012345670" )
209+ testcommon ("%#-38.34o" , big , "0o0012345670123456701234567012345670 " )
210+ testcommon ("%#038.34o" , big , "0o000012345670123456701234567012345670" )
195211 testcommon ("%#+.34o" , big , "+0o0012345670123456701234567012345670" )
196212 testcommon ("%# .34o" , big , " 0o0012345670123456701234567012345670" )
197- testcommon ("%#+.34o" , big , "+0o0012345670123456701234567012345670" )
198- testcommon ("%#-+.34o" , big , "+0o0012345670123456701234567012345670" )
199- testcommon ("%#-+37.34o" , big , "+0o0012345670123456701234567012345670" )
200- testcommon ("%#+37.34o" , big , "+0o0012345670123456701234567012345670" )
213+ testcommon ("%#+38.34o" , big , " +0o0012345670123456701234567012345670" )
214+ testcommon ("%#-+38.34o" , big , "+0o0012345670123456701234567012345670 " )
215+ testcommon ("%#- 38.34o" , big , " 0o0012345670123456701234567012345670 " )
216+ testcommon ("%#+038.34o" , big , "+0o00012345670123456701234567012345670" )
217+ testcommon ("%# 038.34o" , big , " 0o00012345670123456701234567012345670" )
201218 # next one gets one leading zero from precision
202219 testcommon ("%.33o" , big , "012345670123456701234567012345670" )
203220 # base marker added in spite of leading zero (different to Python 2)
@@ -208,6 +225,7 @@ def test_common_format(self):
208225 testcommon ("%035.33o" , big , "00012345670123456701234567012345670" )
209226 # base marker shouldn't change the size
210227 testcommon ("%0#35.33o" , big , "0o012345670123456701234567012345670" )
228+
211229 # Some small ints, in both Python int and flavors).
212230 testcommon ("%d" , 42 , "42" )
213231 testcommon ("%d" , - 42 , "-42" )
0 commit comments