Skip to content

Commit 35a89e1

Browse files
authored
Imporved test coverage in decimal_to_fraction.py
1 parent fff34ed commit 35a89e1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

maths/decimal_to_fraction.py

+15
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,23 @@ def decimal_to_fraction(decimal: float | str) -> tuple[int, int]:
1414
>>> decimal_to_fraction("6.25")
1515
(25, 4)
1616
>>> decimal_to_fraction("78td")
17+
1718
Traceback (most recent call last):
1819
ValueError: Please enter a valid number
20+
>>> decimal_to_fraction(0)
21+
(0,1)
22+
>>>decima_to_fraction(-2.5)
23+
(-5,2)
24+
>>> >>> decimal_to_fraction(0.125)
25+
(1,8)
26+
>>> decimal_to_fraction(1000000.25)
27+
(4000001, 400)
28+
>>> decimal_to_fraction(1.3333)
29+
(133333, 10000)
30+
>>> decimal_to_fraction(1.23e2)
31+
(123, 1)
32+
>>> decimal_to_fraction("0.0500")
33+
(1,2)
1934
"""
2035
try:
2136
decimal = float(decimal)

0 commit comments

Comments
 (0)