From eceeafe022404cffd7a87f95d5ebff617149b644 Mon Sep 17 00:00:00 2001 From: fdai7764 Date: Sat, 27 Jan 2024 14:30:57 +0100 Subject: [PATCH] added test for new function sqrt_power as well as corresponding functionality --- src/main/py/calculations_with_roots.py | 7 +++++-- src/test/py/test_calculations_with_roots.py | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/py/calculations_with_roots.py b/src/main/py/calculations_with_roots.py index 770cd14..f453bff 100644 --- a/src/main/py/calculations_with_roots.py +++ b/src/main/py/calculations_with_roots.py @@ -1,6 +1,9 @@ -from src.main.py.logarithmic_and_expo_and_root_calculations import sqrt +from src.main.py.logarithmic_and_expo_and_root_calculations import * def multiplyRoots(first_number, second_number): if first_number < 0 or second_number < 0: return -1 - return sqrt(first_number * second_number) \ No newline at end of file + return sqrt(first_number * second_number) + +def sqrt_power(base, exponent): + return potentiate(sqrt(base), exponent) \ No newline at end of file diff --git a/src/test/py/test_calculations_with_roots.py b/src/test/py/test_calculations_with_roots.py index 66fc1e1..deaec8b 100644 --- a/src/test/py/test_calculations_with_roots.py +++ b/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): self.assertEqual(multiplyRoots(-2, -8), -1) + def test_sqrt_4_to_power_of_3_should_be_8(self): + self.assertEqual(sqrt_power(4, 3), 8) + if __name__ == '__main__': unittest.main()