Example #1
0
        public void TestAdd(double a, double b, double res)
        {
            IRPNCalculator c = new RPNCalculator();

            c.Push(a);
            c.Push(b);
            c.Add();
            Assert.True(c.Top() == res);
        }
Example #2
0
        public void TestMul(double a, double b, double res)
        {
            IRPNCalculator c = new RPNCalculator();

            Assert.True(c.Size() == 0);
            c.Push(a);
            c.Push(b);
            Assert.True(c.Size() == 2 && c.Top() == 5);
            c.Multiply();
            Assert.True(c.Size() == 1 && c.Top() == res);
        }
Example #3
0
        public void TestPop()
        {
            IRPNCalculator c = new RPNCalculator();

            Assert.True(c.Size() == 0);
            c.Push(6);
            c.Push(5);
            Assert.True(c.Size() == 2 && c.Top() == 5);
            c.Pop();
            Assert.True(c.Size() == 1 && c.Top() == 6);
        }
Example #4
0
        public void TestClear()
        {
            IRPNCalculator c = new RPNCalculator();

            Assert.True(c.Size() == 0);
            c.Push(5);
            c.Push(5);
            Assert.True(c.Size() == 2);
            c.Clear();
            Assert.True(c.Size() == 0);
        }
Example #5
0
        public void TestDivZero()
        {
            IRPNCalculator cal = new RPNCalculator();

            Assert.True(cal.Size() == 0);
            cal.Push(0);
            cal.Push(5);
            Assert.Throws <ArgumentException>(() => cal.Divide());
            cal.Add();
            Assert.True(cal.Size() == 1);
        }
Example #6
0
        public void TestDiv(double a, double b, double res)
        {
            IRPNCalculator c = new RPNCalculator();

            Assert.True(c.Size() == 0);
            c.Push(a);
            c.Push(b);
            Assert.True(c.Size() == 2 && c.Top() == b);
            c.Divide();
            Assert.True(c.Size() == 1 && c.Top() == res);
        }
Example #7
0
        public void TestMoreMaths(double a, double b, double c, double res)
        {
            IRPNCalculator cal = new RPNCalculator();

            Assert.True(cal.Size() == 0);
            cal.Push(a);
            cal.Push(b);
            cal.Push(c);
            Assert.True(cal.Size() == 3 && cal.Top() == 5);
            cal.Add();
            cal.Multiply();
            Assert.True(cal.Top() == res && cal.Size() == 1);
        }
Example #8
0
        public void TestPushAndTop()
        {
            IRPNCalculator c = new RPNCalculator();

            c.Push(5);
            Assert.True(c.Top() == 5);
        }