Browse Source

added test for division of two roots as well as corresponding functionality

remotes/origin/feature/feature-calculations_with_roots
fdai7764 11 months ago
parent
commit
0bf973569c
  1. 3
      src/main/py/calculations_with_roots.py
  2. 3
      src/test/py/test_calculations_with_roots.py

3
src/main/py/calculations_with_roots.py

@ -5,6 +5,9 @@ def multiplyRoots(first_number, second_number):
return -1 return -1
return sqrt(first_number * second_number) return sqrt(first_number * second_number)
def divideRoots(first_number, second_number):
return sqrt(first_number / second_number)
def sqrt_power(base, exponent): def sqrt_power(base, exponent):
if base < 0: if base < 0:
return -1 return -1

3
src/test/py/test_calculations_with_roots.py

@ -18,6 +18,9 @@ class calculationsWithRoots(unittest.TestCase):
def test_sqrt_negative_2_times_sqrt_negative_8_should_be_negative_one_for_error(self): def test_sqrt_negative_2_times_sqrt_negative_8_should_be_negative_one_for_error(self):
self.assertEqual(multiplyRoots(-2, -8), -1) self.assertEqual(multiplyRoots(-2, -8), -1)
def test_divide_sqrt_16_by_sqrt_4_should_be_2(self):
self.assertEqual(divideRoots(16,4), 2)
def test_sqrt_4_to_power_of_3_should_be_8(self): def test_sqrt_4_to_power_of_3_should_be_8(self):
self.assertEqual(sqrt_power(4, 3), 8) self.assertEqual(sqrt_power(4, 3), 8)

Loading…
Cancel
Save