@ -6,3 +6,9 @@ def read_constant(type, value):
def is_string(value):
return isinstance(value, str)
def is_allowed_string(type, value):
allowed = "+-*/()^"
result = all(character.isdigit() or character in allowed for character in value)
return result
@ -11,6 +11,8 @@ class read_function(unittest.TestCase):
self.assertEqual(is_string("42*e^x"), True)
def test_constant_isstring_false(self):
self.assertEqual(is_string(42), False)
def test_constant_isallowed_string_true(self):
self.assertEqual(is_allowed_string("c", "42^(2)+1-3*4"), True)
if __name__ == '__main__':
unittest.main()