From f8763667ac8ba76af259db7c0fea04b159604e9f Mon Sep 17 00:00:00 2001 From: satyakam Date: Sat, 10 Oct 2026 02:12:34 +0530 Subject: [PATCH] added new tests for temperature conversion and also fixed the convert from mile to km logic --- fixit/convert.py | 2 +- tests/test_convert.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/fixit/convert.py b/fixit/convert.py index 845b8ba..400b081 100644 --- a/fixit/convert.py +++ b/fixit/convert.py @@ -16,4 +16,4 @@ def km_to_miles(km: float) -> float: def miles_to_km(miles: float) -> float: - return miles / KM_PER_MILE + return miles * KM_PER_MILE diff --git a/tests/test_convert.py b/tests/test_convert.py index 196453e..80c2bf1 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -15,6 +15,18 @@ def test_km_to_miles(): assert km_to_miles(10) == pytest.approx(6.21371, rel=1e-4) -@pytest.mark.xfail(reason="Known bug: miles_to_km divides instead of multiplies") def test_miles_to_km(): assert miles_to_km(1) == pytest.approx(1.609344) + + +def test_negative_celsius(): + assert celsius_to_fahrenheit(-20)==-4 + +def test_zero_celsius(): + assert celsius_to_fahrenheit(0) == 32 + +def test_absolute_zero(): + assert celsius_to_fahrenheit(-273.15) == pytest.approx(-459.67) + +def test_float_km_to_miles(): + assert km_to_miles(1.5) == pytest.approx(0.932056788) \ No newline at end of file