Browse Source

refactoring: added new lines

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

11
src/test/py/test_read_math_function.py

@ -2,6 +2,7 @@ import unittest
from src.main.py.read_math_function import *
from unittest.mock import patch
class read_function(unittest.TestCase):
def test_constant_without_calculation(self):
self.assertEqual(simplify_constant("c", 42), 42)
@ -33,31 +34,39 @@ class read_function(unittest.TestCase):
def test_constant_string_not_allowed_decision(self):
self.assertEqual(simplify_constant("c", "42^(2)+1-3*4/3x"), False)
@patch('builtins.input', side_effect=["x"])
def test_read_math_function_false_if_enter_x(self, mock_input):
result = read_math_function()
self.assertFalse(result)
@patch('builtins.input', side_effect=["c", "5"])
def test_read_math_function_return5_if_enter_c_5(self, mock_input):
self.assertEqual(read_math_function(), 5)
def test_easy_function_wrong_type(self):
self.assertEqual(simplify_easy_math_function("a", "42x"), False)
def test_easy_function_number_as_function_return(self):
self.assertEqual(simplify_easy_math_function("v", 42), 42)
def test_easy_function_string_is_constant(self):
self.assertEqual(simplify_easy_math_function("v", "42^(2)+1-3*4/3"), 1761)
def test_extraction_linear_function_constant_without_math_operators_addition(self):
self.assertEqual(extract_constant("42x+5"), ["5", "42x"])
def test_extraction_linear_function_constant_without_math_operators_subtraction(self):
self.assertEqual(extract_constant("42x-5"), ["-5", "42x"])
def test_extraction_linear_function_no_constant(self):
self.assertEqual(extract_constant("42x"), ["0", "42x"])
def test_extraction_linear_function_constant_with_math_operators(self):
self.assertEqual(extract_constant("42x+42^(2)+1-3*4/3"), ["42^(2)+1-3*4/3", "42x"])
def test_easy_function_linear_constant_gets_simplified(self):
self.assertEqual(simplify_easy_math_function("v", "42x+42^(2)+1-3*4/3"), [1761, "42x"])
if __name__ == '__main__':
unittest.main()
Loading…
Cancel
Save