From c372688e958a02ded7f0c4d2e44db487df851101 Mon Sep 17 00:00:00 2001 From: fdai7763 Date: Tue, 23 Jan 2024 21:03:32 +0100 Subject: [PATCH] added test for decision to calculate string with calculate_string as well as corresponding functionality --- src/main/py/read_math_function.py | 4 ++++ src/test/py/test_read_math_function.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/main/py/read_math_function.py b/src/main/py/read_math_function.py index 4df38f6..b51bb8a 100644 --- a/src/main/py/read_math_function.py +++ b/src/main/py/read_math_function.py @@ -1,6 +1,10 @@ def read_constant(type, value): if type != "c": return False + if is_string(value): + if is_allowed_string(type, value): + constant = calculate_string(value) + return constant return value diff --git a/src/test/py/test_read_math_function.py b/src/test/py/test_read_math_function.py index dab7400..b8fb7d1 100644 --- a/src/test/py/test_read_math_function.py +++ b/src/test/py/test_read_math_function.py @@ -19,6 +19,8 @@ class read_function(unittest.TestCase): self.assertEqual(calculate_string("42+1-3*4/3"), 39) def test_constant_calculate_with_pow(self): self.assertEqual(calculate_string("42^(2)+1-3*4/3"), 1761) + def test_constant_calculate_string_decision(self): + self.assertEqual(read_constant("c", "42^(2)+1-3*4/3"), 1761) if __name__ == '__main__': unittest.main()