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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void TestPushAndTop() { IRPNCalculator c = new RPNCalculator(); c.Push(5); Assert.True(c.Top() == 5); }