From d08dc04996c2c56587aeca77965180bb259830cc Mon Sep 17 00:00:00 2001 From: fdai7763 Date: Tue, 23 Jan 2024 20:16:21 +0100 Subject: [PATCH] added test for new function returning true if math-function is a string as well as corresponding functionality --- src/main/py/read_math_function.py | 6 +++++- src/test/py/test_read_math_function.py | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/py/read_math_function.py b/src/main/py/read_math_function.py index af12bc3..150f76e 100644 --- a/src/main/py/read_math_function.py +++ b/src/main/py/read_math_function.py @@ -1,4 +1,8 @@ def read_constant(type, value): if type != "c": return False - return value \ No newline at end of file + return value + +def is_string(value): + result = isinstance(value, str) + return result diff --git a/src/test/py/test_read_math_function.py b/src/test/py/test_read_math_function.py index 3ee918b..7ab1836 100644 --- a/src/test/py/test_read_math_function.py +++ b/src/test/py/test_read_math_function.py @@ -7,6 +7,8 @@ class read_function(unittest.TestCase): self.assertEqual(read_constant("c", 42), 42) def test_constant_no_c(self): self.assertEqual(read_constant("e", "42*e^x"), False) + def test_constant_isstring_true(self): + self.assertEqual(is_string("42*e^x"), True) if __name__ == '__main__': unittest.main()