Skip to content

Commit 9ede4dc

Browse files
committed
tests: Add some tests for printing floats to improve coverage.
1 parent 79474c6 commit 9ede4dc

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

tests/float/string_format.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ def test_fmt(conv, fill, alignment, sign, prefix, width, precision, type, arg):
122122
test_fmt('', fill, alignment, sign, '', width, prec, type, num)
123123
for num in pct_nums2:
124124
test_fmt('', fill, alignment, sign, '', width, '', type, num)
125+
else:
126+
for num in pct_nums1:
127+
test_fmt('', '', '', '', '', '', '1', '%', num)
125128

126129
# We don't currently test a type of '' with floats (see the detailed comment
127130
# in objstr.c)

tests/float/string_format_modulo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@
2121
print("%06e" % float("inf"))
2222
print("%06e" % float("-inf"))
2323
print("%06e" % float("nan"))
24+
25+
print("%02.3d" % 123) # prec > width
26+
print("%+f %+f" % (1.23, -1.23)) # float sign
27+
print("% f % f" % (1.23, -1.23)) # float space sign
28+
print("%0f" % -1.23) # negative number with 0 padding

0 commit comments

Comments
 (0)