hbui
2024-07-23 4ac5bac6e8ed741dd2725d221d7702a2eba50c90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import math
import unittest
 
from numint.input_parser import parse_function, parse_value
 
 
class InputParserTestCase(unittest.TestCase):
    def test_common_function(self):
        expr = "tan(radians(x))"
        fn = parse_function(expr)
        tan60 = fn(60)
        self.assertTrue(abs(tan60 - 1.732) < 0.01)  # add assertion here
 
    def test_eval_value(self):
        expr = "e"
        value = parse_value(expr)
        self.assertTrue(abs(value - math.e) < 0.0001)
 
if __name__ == '__main__':
    unittest.main()