public void EvaluateWithCorrectInput() { var polishForm = new PolishForm(("(10+2)*3/4+5*6^2")); var result = polishForm.Evaluate(); Assert.AreEqual(189, result); }
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()); }
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)); } }
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)); } }