コード例 #1
0
        public void Pow_Division_Subtraction_Addition_Doubles()
        {
            double expected = 0.1 + 1.1 / 2.2 + 3.3 * 4.4 + Math.Pow(5.5, 6.6) - 7.7;
            string actual   = ReversePolishNotation.Parse(ReversePolishNotation.Tokenize("0.1 + 1.1 / 2.2 + 3.3 * 4.4 + pow(5.5, 6.6) - 7.7"));

            Assert.AreEqual(expected.ToString(), actual);
        }
コード例 #2
0
        public void Addition_Multiplication_Division_Subtraction()
        {
            double expected = 1111 + 1111 * 1111 / 1111 - 1111;
            string actual   = ReversePolishNotation.Parse(ReversePolishNotation.Tokenize("1111 + 1111 * 1111 / 1111 - 1111"));

            Assert.AreEqual(expected.ToString(), actual);
        }
コード例 #3
0
        public void Addition_Of_Pow_Division_Subtraction_And_Multiplication()
        {
            double expected = 15.5 / 5 + Math.Pow(0.123, 2) - (3.2 * 5);
            string actual   = ReversePolishNotation.Parse(ReversePolishNotation.Tokenize("15.5 / 5 + pow(0.123, 2) - (3.2 * 5)"));

            Assert.AreEqual(expected.ToString(), actual);
        }
コード例 #4
0
        public void Pow_Subtraction_Multiplication_Addition_Division()
        {
            double expected = Math.Pow(3.14, 2) - 15 / 3 + 2 * 3 - (15 + 3);
            string actual   = ReversePolishNotation.Parse(ReversePolishNotation.Tokenize("pow(3.14, 2) - 15 / 3 + 2 * 3 - (15 + 3)"));

            Assert.AreEqual(expected.ToString(), actual);
        }
コード例 #5
0
        public void Addition_Of_Doubles()
        {
            double expected = 1.1 + 2.2 + 3.3 + 4.4 + 5.5 + 6.6;
            string actual   = ReversePolishNotation.Parse(ReversePolishNotation.Tokenize("1.1 + 2.2 + 3.3 + 4.4 + 5.5 + 6.6"));

            Assert.AreEqual(expected.ToString(), actual);
        }
コード例 #6
0
        public void Pow_Of_Two_Doubles()
        {
            double expected = Math.Pow(3.14, 2) + Math.Pow(3.14, 2);
            string actual   = ReversePolishNotation.Parse(ReversePolishNotation.Tokenize("3.14 ^ 2 + pow(3.14, 2)"));

            Assert.AreEqual(expected.ToString(), actual);
        }
コード例 #7
0
        public void Division_And_Multiplication_Of_Sin_Cos_Tan_ln_Sqrt_Pow()
        {
            double expected = Math.Tan(123.12) / Math.Cos(20) / Math.Sin(30) / Math.Cos(12.21) * Math.Sin(21.21)
                              * Math.Tan(20) * Math.Sqrt(121) / Math.Pow(12.12, 2) * Math.Log(12.2, Math.E);
            string actual = ReversePolishNotation.Parse(ReversePolishNotation.Tokenize("Tan(123.12) / Cos(20) / Sin(30) / Cos(12.21) * Sin(21.21) * Tan(20) * Sqrt(121) / Pow(12.12, 2) * ln(12.2, E)"));

            Assert.AreEqual(expected.ToString(), actual);
        }