public void InfixTestNothingAndNull() { var RPC = new ReversePolishCalculator(); RPC.InitOperations(); Assert.AreEqual(0d, RPC.InfixCalculation("")); Assert.AreEqual(0d, RPC.InfixCalculation(null)); }
public void InfixTestPowBeforeX() { var RPC = new ReversePolishCalculator(); RPC.InitOperations(); Assert.AreEqual(1d, RPC.InfixCalculation("1 ^ 2 * 3")); Assert.AreEqual(8d, RPC.InfixCalculation("1 * 2 ^ 3")); }
public void InfixTestComplexExpressions() { var RPC = new ReversePolishCalculator(); RPC.InitOperations(); Assert.AreEqual(2d, RPC.InfixCalculation("( 2 + 2 ) - 2")); Assert.AreEqual(9d, RPC.InfixCalculation("( ( 3 - 2 ) + 2 ) * 3")); Assert.AreEqual(6d, RPC.InfixCalculation("( ( 3 * 3 ) + ( 5 - 2 ) ) / 2")); }
public void InfixTestAllOperaters() { var RPC = new ReversePolishCalculator(); RPC.InitOperations(); Assert.AreEqual(4d, RPC.InfixCalculation("2 + 2")); Assert.AreEqual(1d, RPC.InfixCalculation("3 - 2")); Assert.AreEqual(9d, RPC.InfixCalculation("3 * 3")); Assert.AreEqual(1d, RPC.InfixCalculation("3 / 3")); Assert.AreEqual(81d, RPC.InfixCalculation("3 ^ 4")); Assert.AreEqual(2d, RPC.InfixCalculation("abs ( 2 - 4 )")); Assert.AreEqual(3d, RPC.InfixCalculation("sqrt ( 9 )")); }
public void InfixTestXBeforePlus() { var RPC = new ReversePolishCalculator(); RPC.InitOperations(); Assert.AreEqual(7d, RPC.InfixCalculation("1 + 2 * 3")); Assert.AreEqual(5d, RPC.InfixCalculation("1 * 2 + 3")); Assert.AreEqual(33d, RPC.InfixCalculation("5 + ( 1 + 2 * 3 ) * 4")); }
public void InfixTestShouldGive14() { var RPC = new ReversePolishCalculator(); RPC.InitOperations(); Assert.AreEqual(14d, RPC.InfixCalculation("( 5 + ( ( 1 + 2 ) * 4 ) ) - 3")); }
public void TestShouldGive14() { var RPC = new ReversePolishCalculator(); RPC.InitOperations(); Assert.AreEqual(14d, RPC.Calculation("5 1 2 + 4 * + 3 -")); }
public void TestComplexExpressions() { var RPC = new ReversePolishCalculator(); RPC.InitOperations(); Assert.AreEqual(2d, RPC.Calculation("2 2 + 2 -")); Assert.AreEqual(9d, RPC.Calculation("3 2 - 2 + 3 *")); Assert.AreEqual(6d, RPC.Calculation("3 3 * 5 2 - + 2 /")); }
public void TestAllOperaters() { var RPC = new ReversePolishCalculator(); RPC.InitOperations(); Assert.AreEqual(4d, RPC.Calculation("2 2 +")); Assert.AreEqual(1d, RPC.Calculation("3 2 -")); Assert.AreEqual(9d, RPC.Calculation("3 3 *")); Assert.AreEqual(1d, RPC.Calculation("3 3 /")); Assert.AreEqual(81d, RPC.Calculation("3 4 ^")); Assert.AreEqual(2d, RPC.Calculation("2 4 - abs")); Assert.AreEqual(3d, RPC.Calculation("9 sqrt")); }