Browse Source

added test for decision to return False when string isn't allowed as well as corresponding functionality

remotes/origin/feature/feature-read-math-functions
fdai7763 11 months ago
parent
commit
ded3c9ef82
  1. 2
      src/main/py/read_math_function.py
  2. 2
      src/test/py/test_read_math_function.py

2
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

2
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()
Loading…
Cancel
Save