Skip to content
Snippets Groups Projects
Commit bfb48c16 authored by Damien George's avatar Damien George
Browse files

tests/float: Add tests for round() of inf, nan and large number.

parent c236ebfe
No related branches found
No related tags found
No related merge requests found
...@@ -15,3 +15,10 @@ for i in range(11): ...@@ -15,3 +15,10 @@ for i in range(11):
# test second arg # test second arg
for i in range(-1, 3): for i in range(-1, 3):
print(round(1.47, i)) print(round(1.47, i))
# test inf and nan
for val in (float('inf'), float('nan')):
try:
round(val)
except (ValueError, OverflowError) as e:
print(type(e))
# test round() with floats that return large integers
for x in (-1e25, 1e25):
print('%.3g' % round(x))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment