Example #1
0
        public void EvaluateWithCorrectInput()
        {
            var polishForm = new PolishForm(("(10+2)*3/4+5*6^2"));
            var result     = polishForm.Evaluate();

            Assert.AreEqual(189, result);
        }
Example #2
0
        static void Main(string[] args)
        {
            //create a polish form object
            var polishForm = new PolishForm(("(10+2)*3/4+5*6^2"));

            //Print the original and polishform expression
            Console.WriteLine(polishForm);
            //Get the result
            Console.WriteLine("The result is " + polishForm.Evaluate());
        }
Example #3
0
 public void EvaluateWithIrregularBrackets()
 {
     try
     {
         var polishForm = new PolishForm(("(10+2)*3/4+(5*6^2"));
         var result     = polishForm.Evaluate();
     }
     catch (FormatException fExp)
     {
         Assert.IsInstanceOfType(fExp, typeof(FormatException));
     }
 }
Example #4
0
 public void EvaluateWithDoubledOperatorInput()
 {
     try
     {
         var polishForm = new PolishForm(("(10++2)*3/4+5*6^2"));
         var result     = polishForm.Evaluate();
     }
     catch (ArgumentException aExp)
     {
         Assert.IsInstanceOfType(aExp, typeof(ArgumentException));
     }
 }