示例#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);
        }
示例#2
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);
        }
示例#3
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);
        }