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 TestNothingAndNull() { var RPC = new ReversePolishCalculator(); RPC.InitOperations(); Assert.AreEqual(0d, RPC.Calculation("")); Assert.AreEqual(0d, RPC.Calculation(null)); }
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")); }