コード例 #1
0
        [Test] public void FloatMath()
        {
            Assert.AreEqual(2f + 3f, GenericOperator.Add(2f, 3f));
            Assert.AreEqual(2f - 3f, GenericOperator.Subtract(2f, 3f));
            Assert.AreEqual(2f * 3f, GenericOperator.Multiply(2f, 3f));
            Assert.AreEqual(2f / 3f, GenericOperator.Divide(2f, 3f));

            Assert.AreEqual(Math.Abs(-5f), GenericOperator.Abs(-5f));
            Assert.AreEqual(5f % 4f, GenericOperator.Modulo(5f, 4f));
            Assert.AreEqual(-5f, GenericOperator.Negate(5f));

            Assert.AreEqual(5f == 4f, GenericOperator.Equal(5f, 4f));
            Assert.AreEqual(5f == 5f, GenericOperator.Equal(5f, 5f));
            Assert.AreEqual(5f > 4f, GenericOperator.GreaterThan(5f, 4f));
            Assert.AreEqual(5f >= 5f, GenericOperator.GreaterThanOrEqual(5f, 5f));
            Assert.AreEqual(5f < 4f, GenericOperator.LessThan(5f, 4f));
            Assert.AreEqual(5f <= 5f, GenericOperator.LessThanOrEqual(5f, 5f));
        }
コード例 #2
0
        [Test] public void IntMath()
        {
            Assert.AreEqual(2 + 3, GenericOperator.Add(2, 3));
            Assert.AreEqual(2 - 3, GenericOperator.Subtract(2, 3));
            Assert.AreEqual(2 * 3, GenericOperator.Multiply(2, 3));
            Assert.AreEqual(2 / 3, GenericOperator.Divide(2, 3));

            Assert.AreEqual(Math.Abs(-5), GenericOperator.Abs(-5));
            Assert.AreEqual(5 % 4, GenericOperator.Modulo(5, 4));
            Assert.AreEqual(-5, GenericOperator.Negate(5));

            Assert.AreEqual(5 == 4, GenericOperator.Equal(5, 4));
            Assert.AreEqual(5 == 5, GenericOperator.Equal(5, 5));
            Assert.AreEqual(5 > 4, GenericOperator.GreaterThan(5, 4));
            Assert.AreEqual(5 >= 5, GenericOperator.GreaterThanOrEqual(5, 5));
            Assert.AreEqual(5 < 4, GenericOperator.LessThan(5, 4));
            Assert.AreEqual(5 <= 5, GenericOperator.LessThanOrEqual(5, 5));
        }