예제 #1
0
        public void CalculateTest()
        {
            string input = "1,23E+2*5+(3/(4-1))*-1";
            double expected = 614.0;

            var parser = new MathParser(input);
            double actual = parser.Calculate();

            Assert.AreEqual(expected,actual,1e-6);
        }
예제 #2
0
        public void CalculateConstantsTest()
        {
            string input = "sin(90*PI/180)*e";
            double expected = Math.Sin(90*Math.PI/180.0)*Math.E;

            var parser = new MathParser(input);
            double actual = parser.Calculate();

            Assert.AreEqual(expected, actual, 1e-6);
        }
예제 #3
0
        public void RadiansTest()
        {
            MathParser parser = new MathParser("sin90");
            double actual = parser.Calculate(useRadians: false);
            double expected = 1.0;
            Assert.AreEqual(expected,actual,1e-6);

            actual = parser.Calculate();
            expected = Math.Sin(90);
            Assert.AreEqual(expected,actual,1e-6);
        }