public void powerOperator() { RPN test = new RPN("(2/2)^1").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(1, math.Compute()); }
public void GreaterThan() { RPN test = new RPN("5 > 2").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(1, math.Compute()); test.SetEquation("5 > 10").Compute(); math = new PostFix(test); Assert.AreEqual(0, math.Compute()); test.SetEquation("5 >= 5").Compute(); math = new PostFix(test); Assert.AreEqual(1, math.Compute()); test.SetEquation("15 >= 5").Compute(); math = new PostFix(test); Assert.AreEqual(1, math.Compute()); test.SetEquation("5 >= 15").Compute(); math = new PostFix(test); Assert.AreEqual(0, math.Compute()); }
public void GCD() { RPN test = new RPN("gcd(123,277)").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(1, math.Compute()); }
public void ComplexIncrement() { RPN test = new RPN("2++ + 2 + 2").Compute(); PostFix math = new PostFix(test.Data); Assert.AreEqual(7, math.Compute()); }
public void SqrtSubtraction() { RPN test = new RPN("sqrt(-1) - sqrt(-1)").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(double.NaN, math.Compute()); }
public void VardiacUltimateStressTest() { RPN test = new RPN("total( sqrt(16), min(0,1), pi, sin(2pi), max(1,2,3), avg(10,5,7,9) ) - total( sqrt(16), min(0,1), pi, sin(2pi), max(1,2,3), avg(10,5,7,9) )").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(0, math.Compute()); }
public void UnarySubtract() { RPN test = new RPN("-2 + 4").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(2, math.Compute()); }
public void Abs() { RPN test = new RPN("abs(-1)").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(1, math.Compute()); }
public void SqrtReduction() { RPN test = new RPN("sqrt(-1)^2").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(-1, math.Compute()); }
public void Increment() { RPN test = new RPN("7++").Compute(); PostFix math = new PostFix(test.Data); Assert.AreEqual(8, math.Compute()); }
public void Arccos() { RPN test = new RPN("arccos( cos(pi/2) )").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(Math.PI / 2, math.Compute()); }
public void VardiacConstantAdd() { var foo = new RPN("pi(2) + e(2)").Compute(); PostFix math = new PostFix(foo); Assert.AreEqual(11.7197489640976, math.Compute(), 0.00001); }
public void Min() { RPN test = new RPN("min(0, 1)").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(0, math.Compute()); }
public void VardiacCompositeConstants() { RPN test = new RPN("sin( max(2,3,4) * pi )").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(0, math.Compute()); }
public void VardiacComposite() { RPN test = new RPN("sin(min (0, 1) )").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(0, math.Compute()); }
public void VardiacMin() { RPN test = new RPN("min(1, 2, 3)").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(1, math.Compute()); }
public void Mod() { RPN test = new RPN("5 % 2").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(1, math.Compute()); }
public void Arctan() { RPN test = new RPN("arctan( tan(pi/4) )").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(Math.PI / 4, math.Compute()); }
public void LCM() { RPN test = new RPN("lcm(1000,625)").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(5000, math.Compute()); }
public void DivideByZero() { RPN test = new RPN("1/0").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(double.NaN, math.Compute()); }
public void LN() { RPN test = new RPN("ln(e)").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(1, math.Compute()); }
public void ExponentianOperator() { RPN test = new RPN("1E3").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(1000, math.Compute()); }
public void Distance() { RPN test = new RPN("sqrt(2^2 + 8^2)").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(Math.Sqrt(68), math.Compute()); }
public void UnarySubtract2() { RPN test = new RPN("5 + -2").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(3, math.Compute()); }
public void VardiacImplicitMultiplication2() { RPN test = new RPN("total(1,4,5)3").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(30, math.Compute()); }
public void Factorial() { RPN test = new RPN("5!").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(120, math.Compute()); }
public void Substract() { RPN test = new RPN("5 - 2").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(3, math.Compute()); }
public void Round() { RPN test = new RPN("round(pi,2)").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(3.14, math.Compute()); }
public void UnaryDecimal() { RPN test = new RPN("-.5 + .5").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(0, math.Compute()); }
public void CompositeFunctions() { RPN test = new RPN("max( sqrt( 16 ) , 100)").Compute(); PostFix math = new PostFix(test); Assert.AreEqual(100, math.Compute()); }