Browse Source

refactoring: added new lines

remotes/origin/feature/feature-read-math-functions
fdai7763 11 months ago
parent
commit
fb17b15e1d
  1. 10
      src/test/py/test_read_math_function.py

10
src/test/py/test_read_math_function.py

@ -5,25 +5,35 @@ from unittest.mock import patch
class read_function(unittest.TestCase): class read_function(unittest.TestCase):
def test_constant_without_calculation(self): def test_constant_without_calculation(self):
self.assertEqual(simplify_constant("c", 42), 42) self.assertEqual(simplify_constant("c", 42), 42)
def test_constant_no_c(self): def test_constant_no_c(self):
self.assertEqual(simplify_constant("e", "42*e^x"), False) self.assertEqual(simplify_constant("e", "42*e^x"), False)
def test_constant_isstring_true(self): def test_constant_isstring_true(self):
self.assertEqual(is_string("42*e^x"), True) self.assertEqual(is_string("42*e^x"), True)
def test_constant_isstring_false(self): def test_constant_isstring_false(self):
self.assertEqual(is_string(42), False) self.assertEqual(is_string(42), False)
def test_constant_isallowed_string_true(self): def test_constant_isallowed_string_true(self):
self.assertEqual(is_allowed_string("c", "42^(2)+1-3*4/3"), True) self.assertEqual(is_allowed_string("c", "42^(2)+1-3*4/3"), True)
def test_constant_isallowed_string_false(self): def test_constant_isallowed_string_false(self):
self.assertEqual(is_allowed_string("c", "42^(2)+1-3*4/3x"), False) self.assertEqual(is_allowed_string("c", "42^(2)+1-3*4/3x"), False)
def test_constant_calculate_without_pow(self): def test_constant_calculate_without_pow(self):
self.assertEqual(calculate_constant_string("42+1-3*4/3"), 39) self.assertEqual(calculate_constant_string("42+1-3*4/3"), 39)
def test_constant_calculate_with_pow(self): def test_constant_calculate_with_pow(self):
self.assertEqual(calculate_constant_string("42^(2)+1-3*4/3"), 1761) self.assertEqual(calculate_constant_string("42^(2)+1-3*4/3"), 1761)
def test_constant_calculate_string_decision(self): def test_constant_calculate_string_decision(self):
self.assertEqual(simplify_constant("c", "42^(2)+1-3*4/3"), 1761) self.assertEqual(simplify_constant("c", "42^(2)+1-3*4/3"), 1761)
def test_constant_string_not_allowed_decision(self): def test_constant_string_not_allowed_decision(self):
self.assertEqual(simplify_constant("c", "42^(2)+1-3*4/3x"), False) self.assertEqual(simplify_constant("c", "42^(2)+1-3*4/3x"), False)
@patch('builtins.input', side_effect=["x"]) @patch('builtins.input', side_effect=["x"])
def test_read_math_function_false_if_enter_x(self, mock_input): def test_read_math_function_false_if_enter_x(self, mock_input):
result = read_math_function() result = read_math_function()

Loading…
Cancel
Save