Example #1
0
        public void TestAllOperaters()
        {
            var RPC = new ReversePolishCalculator();

            Assert.AreEqual(4d, RPC.reversePolishNotation("2 2 +"));
            Assert.AreEqual(1d, RPC.reversePolishNotation("3 2 -"));
            Assert.AreEqual(9d, RPC.reversePolishNotation("3 3 *"));
            Assert.AreEqual(1d, RPC.reversePolishNotation("3 3 /"));
            Assert.AreEqual(81d, RPC.reversePolishNotation("3 4 ^"));
        }
Example #2
0
        public void TestNothingAndNull()
        {
            var RPC = new ReversePolishCalculator();

            Assert.AreEqual(0d, RPC.reversePolishNotation(""));
            Assert.AreEqual(0d, RPC.reversePolishNotation(null));
        }
Example #3
0
        public void TestShouldGive14()
        {
            var RPC = new ReversePolishCalculator();

            Assert.AreEqual(14d, RPC.reversePolishNotation("5 1 2 + 4 * + 3 -"));
        }
Example #4
0
        public void TestComplexExpressions()
        {
            var RPC = new ReversePolishCalculator();

            Assert.AreEqual(2d, RPC.reversePolishNotation("2 2 + 2 -"));
            Assert.AreEqual(9d, RPC.reversePolishNotation("3 2 - 2 + 3 *"));
            Assert.AreEqual(6d, RPC.reversePolishNotation("3 3 * 5 2 - + 2 /"));
        }