diff --git a/src/main/py/trigonometry.py b/src/main/py/trigonometry.py index d679dea..c2e6635 100644 --- a/src/main/py/trigonometry.py +++ b/src/main/py/trigonometry.py @@ -2,6 +2,8 @@ import math from src.main.py.logarithmic_and_expo_and_root_calculations import potentiate def pi_approx_leibniz(precision): + if precision < 0: + return -1 result = 0 for i in range(precision): num = potentiate(-1, i) diff --git a/src/test/py/test_trigonometry.py b/src/test/py/test_trigonometry.py index f4b7442..8e06ee1 100644 --- a/src/test/py/test_trigonometry.py +++ b/src/test/py/test_trigonometry.py @@ -15,6 +15,9 @@ class MyTestCase(unittest.TestCase): delta *= -1 self.assertLess(delta, 0.01) + def test_pi_precision_negative_10_should_be_negative_1_for_error(self): + self.assertEqual(pi_approx_leibniz(-10), -1) + def test_rad_2_to_deg_should_be_114_point_59(self): delta = rad2deg(2) - 114.59 if delta < 0: