Beispiel #1
0
        public void DivTest()
        {
            //check div(int a, int b)
            Assert.AreEqual(5, OwnMath.div(10, 2));
            Assert.AreEqual(-5, OwnMath.div(-10, 2));
            Assert.AreEqual(0, OwnMath.div(0, 2));
            Assert.ThrowsException <Exception>(() => (OwnMath.div(2, 0)));

            //check div(double a, int b)
            Assert.AreEqual(5.25, OwnMath.div(10.5, 2));
            Assert.AreEqual(-5.25, OwnMath.div(-10.5, 2));
            Assert.AreEqual(0, OwnMath.div(0.0, 2));
            Assert.ThrowsException <Exception>(() => (OwnMath.div(2.5, 0)));

            //check div(int a, double b)
            Assert.AreEqual(4, OwnMath.div(10, 2.5));
            Assert.AreEqual(-4, OwnMath.div(-10, 2.5));
            Assert.AreEqual(0, OwnMath.div(0, 2.5));

            //check mul(double a, double b)
            Assert.AreEqual(4.2, OwnMath.div(10.5, 2.5));
            Assert.AreEqual(-4.2, OwnMath.div(-10.5, 2.5));

            //check divInt(int a, int b)
            Assert.AreEqual(5, OwnMath.divInt(10, 2));
            Assert.AreEqual(-5, OwnMath.divInt(-10, 2));
            Assert.AreEqual(0, OwnMath.divInt(0, 2));
            Assert.ThrowsException <Exception>(() => (OwnMath.divInt(2, 0)));
        }