|
|
@ -4,9 +4,9 @@ from src.main.py.read_math_function import * |
|
|
|
|
|
|
|
class read_function(unittest.TestCase): |
|
|
|
def test_constant_without_calculation(self): |
|
|
|
self.assertEqual(read_constant("c", 42), 42) |
|
|
|
self.assertEqual(simplify_constant("c", 42), 42) |
|
|
|
def test_constant_no_c(self): |
|
|
|
self.assertEqual(read_constant("e", "42*e^x"), False) |
|
|
|
self.assertEqual(simplify_constant("e", "42*e^x"), False) |
|
|
|
def test_constant_isstring_true(self): |
|
|
|
self.assertEqual(is_string("42*e^x"), True) |
|
|
|
def test_constant_isstring_false(self): |
|
|
@ -16,13 +16,13 @@ class read_function(unittest.TestCase): |
|
|
|
def test_constant_isallowed_string_false(self): |
|
|
|
self.assertEqual(is_allowed_string("c", "42^(2)+1-3*4/3x"), False) |
|
|
|
def test_constant_calculate_without_pow(self): |
|
|
|
self.assertEqual(calculate_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): |
|
|
|
self.assertEqual(calculate_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): |
|
|
|
self.assertEqual(read_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): |
|
|
|
self.assertEqual(read_constant("c", "42^(2)+1-3*4/3x"), False) |
|
|
|
self.assertEqual(simplify_constant("c", "42^(2)+1-3*4/3x"), False) |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
unittest.main() |