From ded3c9ef8241c206acbd49760f566dc7a7c976ae Mon Sep 17 00:00:00 2001 From: fdai7763 Date: Tue, 23 Jan 2024 21:06:37 +0100 Subject: [PATCH] added test for decision to return False when string isn't allowed as well as corresponding functionality --- src/main/py/read_math_function.py | 2 ++ src/test/py/test_read_math_function.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/main/py/read_math_function.py b/src/main/py/read_math_function.py index 0b2cdd9..00a9327 100644 --- a/src/main/py/read_math_function.py +++ b/src/main/py/read_math_function.py @@ -4,6 +4,8 @@ def read_constant(type, value): if is_string(value): if is_allowed_string(type, value): return calculate_string(value) + else: + return False return value diff --git a/src/test/py/test_read_math_function.py b/src/test/py/test_read_math_function.py index b8fb7d1..0fe03d2 100644 --- a/src/test/py/test_read_math_function.py +++ b/src/test/py/test_read_math_function.py @@ -21,6 +21,8 @@ class read_function(unittest.TestCase): 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) + def test_constant_string_not_allowed_decision(self): + self.assertEqual(read_constant("c", "42^(2)+1-3*4/3x"), False) if __name__ == '__main__': unittest.main()