/// <summary> /// Does the math operation. /// </summary> private void do_math_operation() { /// <sumamry> Variable lastOperator stores last operation which will be performed </summary> switch (lastOperator) { case "+": operand1 = Math.Add(operand1, dispString_to_numb(display.Text)); break; case "-": operand1 = Math.Add(operand1, -(dispString_to_numb(display.Text))); break; case "*": operand1 = Math.Mul(operand1, dispString_to_numb(display.Text)); break; case "/": operand1 = Math.Div(operand1, dispString_to_numb(display.Text)); break; case "power": operand1 = Math.Pow(operand1, dispString_to_numb(display.Text)); break; case "root": operand1 = Math.Root(operand1, dispString_to_numb(display.Text)); break; case "log": operand1 = Math.Log(dispString_to_numb(display.Text), operand1); break; default: break; } }
public void AddTest() { Assert.AreEqual(0, math.Add(0, 0)); Assert.AreEqual(20, math.Add(5, 15)); Assert.AreEqual(-12, math.Add(60, -72)); Assert.AreEqual(-10, math.Add(-6, -4)); Assert.AreEqual(48, math.Add(50, -2)); Assert.AreEqual(-4000000, math.Add(-7000000, 3000000)); Assert.AreEqual(128, math.Add(-128, 256)); Assert.AreEqual(4.2, math.Add(6, -1.8), Exactness); Assert.AreEqual(0.5, math.Add(0.15, 0.35), Exactness); Assert.AreEqual(10.65, math.Add(10.1, 0.55), Exactness); Assert.AreEqual(-0.32564, math.Add(0, -0.32564), Exactness); Assert.AreEqual(2.3256, math.Add(2, 0.3256), Exactness); Assert.AreEqual(200000000, math.Add(100000000, 100000000)); }