Пример #1
0
        public void ArithmeticMethods()
        {
            SqlDouble test0   = new SqlDouble(0);
            SqlDouble test1   = new SqlDouble(15E+108);
            SqlDouble test2   = new SqlDouble(-65E+64);
            SqlDouble test3   = new SqlDouble(5E+64);
            SqlDouble test4   = new SqlDouble(5E+108);
            SqlDouble testMax = new SqlDouble(SqlDouble.MaxValue.Value);

            // Add()
            Assert.Equal(15E+108, SqlDouble.Add(test1, test0).Value);
            Assert.Equal(1.5E+109, SqlDouble.Add(test1, test2).Value);

            Assert.Throws <OverflowException>(() => SqlDouble.Add(SqlDouble.MaxValue, SqlDouble.MaxValue));

            // Divide()
            Assert.Equal(3, SqlDouble.Divide(test1, test4));
            Assert.Equal(-13d, SqlDouble.Divide(test2, test3).Value);

            Assert.Throws <DivideByZeroException>(() => SqlDouble.Divide(test1, test0).Value);

            // Multiply()
            Assert.Equal(75E+216, SqlDouble.Multiply(test1, test4).Value);
            Assert.Equal(0, SqlDouble.Multiply(test1, test0).Value);

            Assert.Throws <OverflowException>(() => SqlDouble.Multiply(testMax, test1));


            // Subtract()
            Assert.Equal(1.5E+109, SqlDouble.Subtract(test1, test3).Value);

            Assert.Throws <OverflowException>(() => SqlDouble.Subtract(SqlDouble.MinValue, SqlDouble.MaxValue));
        }
Пример #2
0
        public void ArithmeticMethods()
        {
            SqlDouble Test0   = new SqlDouble(0);
            SqlDouble Test1   = new SqlDouble(15E+108);
            SqlDouble Test2   = new SqlDouble(-65E+64);
            SqlDouble Test3   = new SqlDouble(5E+64);
            SqlDouble Test4   = new SqlDouble(5E+108);
            SqlDouble TestMax = new SqlDouble(SqlDouble.MaxValue.Value);

            // Add()
            Assert.AreEqual(15E+108, SqlDouble.Add(Test1, Test0).Value, "#D01A");
            Assert.AreEqual(1.5E+109, SqlDouble.Add(Test1, Test2).Value, "#D02A");

            try {
                SqlDouble test = SqlDouble.Add(SqlDouble.MaxValue, SqlDouble.MaxValue);
                Assert.Fail("#D03A");
            } catch (OverflowException e) {
                Assert.AreEqual(typeof(OverflowException), e.GetType(), "#D04A");
            }

            // Divide()
            Assert.AreEqual((SqlDouble)3, SqlDouble.Divide(Test1, Test4), "#D01B");
            Assert.AreEqual(-13d, SqlDouble.Divide(Test2, Test3).Value, "#D02B");

            try {
                SqlDouble test = SqlDouble.Divide(Test1, Test0).Value;
                Assert.Fail("#D03B");
            } catch (DivideByZeroException e) {
                Assert.AreEqual(typeof(DivideByZeroException), e.GetType(), "#D04B");
            }

            // Multiply()
            Assert.AreEqual((double)(75E+216), SqlDouble.Multiply(Test1, Test4).Value, "#D01D");
            Assert.AreEqual((double)0, SqlDouble.Multiply(Test1, Test0).Value, "#D02D");

            try {
                SqlDouble test = SqlDouble.Multiply(TestMax, Test1);
                Assert.Fail("#D03D");
            } catch (OverflowException e) {
                Assert.AreEqual(typeof(OverflowException), e.GetType(), "#D04D");
            }


            // Subtract()
            Assert.AreEqual((double)1.5E+109, SqlDouble.Subtract(Test1, Test3).Value, "#D01F");

            try {
                SqlDouble test = SqlDouble.Subtract(SqlDouble.MinValue, SqlDouble.MaxValue);
                Assert.Fail("D02F");
            } catch (OverflowException e) {
                Assert.AreEqual(typeof(OverflowException), e.GetType(), "#D03F");
            }
        }
Пример #3
0
        public void ArithmeticMethods()
        {
            SqlDouble Test0   = new SqlDouble(0);
            SqlDouble Test1   = new SqlDouble(15E+108);
            SqlDouble Test2   = new SqlDouble(-65E+64);
            SqlDouble Test3   = new SqlDouble(5E+64);
            SqlDouble Test4   = new SqlDouble(5E+108);
            SqlDouble TestMax = new SqlDouble(SqlDouble.MaxValue.Value);

            // Add()
            Assert.Equal(15E+108, SqlDouble.Add(Test1, Test0).Value);
            Assert.Equal(1.5E+109, SqlDouble.Add(Test1, Test2).Value);

            try
            {
                SqlDouble test = SqlDouble.Add(SqlDouble.MaxValue, SqlDouble.MaxValue);
                Assert.False(true);
            }
            catch (OverflowException e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            // Divide()
            Assert.Equal(3, SqlDouble.Divide(Test1, Test4));
            Assert.Equal(-13d, SqlDouble.Divide(Test2, Test3).Value);

            try
            {
                SqlDouble test = SqlDouble.Divide(Test1, Test0).Value;
                Assert.False(true);
            }
            catch (DivideByZeroException e)
            {
                Assert.Equal(typeof(DivideByZeroException), e.GetType());
            }

            // Multiply()
            Assert.Equal(75E+216, SqlDouble.Multiply(Test1, Test4).Value);
            Assert.Equal(0, SqlDouble.Multiply(Test1, Test0).Value);

            try
            {
                SqlDouble test = SqlDouble.Multiply(TestMax, Test1);
                Assert.False(true);
            }
            catch (OverflowException e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }


            // Subtract()
            Assert.Equal(1.5E+109, SqlDouble.Subtract(Test1, Test3).Value);

            try
            {
                SqlDouble test = SqlDouble.Subtract(SqlDouble.MinValue, SqlDouble.MaxValue);
                Assert.False(true);
            }
            catch (OverflowException e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }
        }