public void Mul() { RPN rpn = new RPN(); Assert.AreEqual(10, rpn.Proc("2*5")); Assert.AreEqual(10, rpn.Proc("2×5")); }
public void Quart() { RPN rpn = new RPN(); Assert.AreEqual((1 + 2) * 3, rpn.Proc("(1+2)*3")); Assert.AreEqual((1.0 + 2.0) * 3.0 / 4.0, rpn.Proc("(1+2)*3/4")); Assert.AreEqual(1 + 2 * (3 + 4) * 5, rpn.Proc("1+2*(3+4)*5")); }
public void Div() { RPN rpn = new RPN(); Assert.AreEqual(1.5, rpn.Proc("3/2")); Assert.AreEqual(1.5, rpn.Proc("3÷2")); Assert.That(() => { RPN rpn = new RPN(); rpn.Proc("1/0"); }, Throws.Exception); }
public void Sin() { RPN rpn = new RPN(); Assert.AreEqual(0, rpn.Proc("sin(3.141592653979)"), 0.1); Assert.AreEqual(0, rpn.Proc("sin(0)")); Assert.AreEqual(1, rpn.Proc("sin(1.5707963268)"), 0.1); Assert.AreEqual(-1, rpn.Proc("sin(-1.5707963268)"), 0.1); Assert.AreEqual(2, rpn.Proc("2*sin(1.5707963268)"), 0.1); Assert.AreEqual(-2, rpn.Proc("2*sin(-1.5707963268)"), 0.1); Assert.AreEqual(1.5, rpn.Proc("1.5sin(1.5707963268)"), 0.1); Assert.AreEqual(0.5, rpn.Proc(".5sin(1.5707963268)"), 0.1); Assert.AreEqual(1, rpn.Proc("1.sin(1.5707963268)"), 0.1); Assert.That(() => { RPN rpn = new RPN(); rpn.Proc(".sin(0)"); }, Throws.Exception); }
public void Cos() { RPN rpn = new RPN(); Assert.AreEqual(-1, rpn.Proc("cos(3.141592653979)"), 0.1); Assert.AreEqual(1, rpn.Proc("cos(0)")); Assert.AreEqual(0, rpn.Proc("cos(1.5707963268)"), 0.1); Assert.AreEqual(0, rpn.Proc("cos(1.5707963268)"), 0.1); Assert.AreEqual(-2, rpn.Proc("2cos(3.141592653979)"), 0.1); Assert.AreEqual(2, rpn.Proc("2cos(0)")); Assert.AreEqual(1.5, rpn.Proc("1.5cos(0)")); Assert.AreEqual(0.5, rpn.Proc(".5cos(0)")); Assert.AreEqual(1, rpn.Proc("1.cos(0)")); Assert.That(() => { RPN rpn = new RPN(); rpn.Proc(".cos(0)"); }, Throws.Exception); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.myButton); RPN rpn = new RPN(); button.Text = rpn.Proc("1+2*3+4/5"); button.Click += delegate { button.Text = $"{count++} clicks!"; }; }
public void Minus() { RPN rpn = new RPN(); Assert.AreEqual(-1, rpn.Proc("-1")); }
public void Sub() { RPN rpn = new RPN(); Assert.AreEqual((1 - 2), rpn.Proc("1-2")); }
public void Add() { RPN rpn = new RPN(); Assert.AreEqual(3, rpn.Proc("1+2")); }