public void ArithmeticMethods() { SqlSingle test0 = new SqlSingle(0); SqlSingle test1 = new SqlSingle(15E+18); SqlSingle test2 = new SqlSingle(-65E+6); SqlSingle test3 = new SqlSingle(5E+30); SqlSingle test4 = new SqlSingle(5E+18); SqlSingle testMax = new SqlSingle(SqlSingle.MaxValue.Value); // Add() Assert.Equal(15E+18f, SqlSingle.Add(test1, test0).Value); Assert.Equal(1.5E+19f, SqlSingle.Add(test1, test2).Value); Assert.Throws <OverflowException>(() => SqlSingle.Add(SqlSingle.MaxValue, SqlSingle.MaxValue)); // Divide() Assert.Equal(3, SqlSingle.Divide(test1, test4)); Assert.Equal(-1.3E-23f, SqlSingle.Divide(test2, test3).Value); Assert.Throws <DivideByZeroException>(() => SqlSingle.Divide(test1, test0)); // Multiply() Assert.Equal((float)(7.5E+37), SqlSingle.Multiply(test1, test4).Value); Assert.Equal(0, SqlSingle.Multiply(test1, test0).Value); Assert.Throws <OverflowException>(() => SqlSingle.Multiply(testMax, test1)); // Subtract() Assert.Equal((float)(-5E+30), SqlSingle.Subtract(test1, test3).Value); Assert.Throws <OverflowException>(() => SqlSingle.Subtract(SqlSingle.MinValue, SqlSingle.MaxValue)); }
public void ArithmeticMethods() { SqlSingle Test0 = new SqlSingle(0); SqlSingle Test1 = new SqlSingle(15E+18); SqlSingle Test2 = new SqlSingle(-65E+6); SqlSingle Test3 = new SqlSingle(5E+30); SqlSingle Test4 = new SqlSingle(5E+18); SqlSingle TestMax = new SqlSingle(SqlSingle.MaxValue.Value); // Add() Assert.AreEqual(15E+18f, SqlSingle.Add(Test1, Test0).Value, "#D01A"); Assert.AreEqual(1.5E+19f, SqlSingle.Add(Test1, Test2).Value, "#D02A"); try { SqlSingle test = SqlSingle.Add(SqlSingle.MaxValue, SqlSingle.MaxValue); Assert.Fail("#D03A"); } catch (Exception e) { Assert.AreEqual(typeof(OverflowException), e.GetType(), "#D04A"); } // Divide() Assert.AreEqual((SqlSingle)3, SqlSingle.Divide(Test1, Test4), "#D01B"); Assert.AreEqual(-1.3E-23f, SqlSingle.Divide(Test2, Test3).Value, "#D02B"); try { SqlSingle test = SqlSingle.Divide(Test1, Test0).Value; Assert.Fail("#D03B"); } catch (Exception e) { Assert.AreEqual(typeof(DivideByZeroException), e.GetType(), "#D04B"); } // Multiply() Assert.AreEqual((float)(7.5E+37), SqlSingle.Multiply(Test1, Test4).Value, "#D01D"); Assert.AreEqual((float)0, SqlSingle.Multiply(Test1, Test0).Value, "#D02D"); try { SqlSingle test = SqlSingle.Multiply(TestMax, Test1); Assert.Fail("#D03D"); } catch (Exception e) { Assert.AreEqual(typeof(OverflowException), e.GetType(), "#D04D"); } // Subtract() Assert.AreEqual((float)(-5E+30), SqlSingle.Subtract(Test1, Test3).Value, "#D01F"); try { SqlSingle test = SqlSingle.Subtract( SqlSingle.MinValue, SqlSingle.MaxValue); Assert.Fail("D02F"); } catch (Exception e) { Assert.AreEqual(typeof(OverflowException), e.GetType(), "#D03F"); } }
public void ArithmeticMethods() { SqlSingle Test0 = new SqlSingle(0); SqlSingle Test1 = new SqlSingle(15E+18); SqlSingle Test2 = new SqlSingle(-65E+6); SqlSingle Test3 = new SqlSingle(5E+30); SqlSingle Test4 = new SqlSingle(5E+18); SqlSingle TestMax = new SqlSingle(SqlSingle.MaxValue.Value); // Add() Assert.Equal(15E+18f, SqlSingle.Add(Test1, Test0).Value); Assert.Equal(1.5E+19f, SqlSingle.Add(Test1, Test2).Value); try { SqlSingle test = SqlSingle.Add(SqlSingle.MaxValue, SqlSingle.MaxValue); Assert.False(true); } catch (Exception e) { Assert.Equal(typeof(OverflowException), e.GetType()); } // Divide() Assert.Equal(3, SqlSingle.Divide(Test1, Test4)); Assert.Equal(-1.3E-23f, SqlSingle.Divide(Test2, Test3).Value); try { SqlSingle test = SqlSingle.Divide(Test1, Test0).Value; Assert.False(true); } catch (Exception e) { Assert.Equal(typeof(DivideByZeroException), e.GetType()); } // Multiply() Assert.Equal((float)(7.5E+37), SqlSingle.Multiply(Test1, Test4).Value); Assert.Equal(0, SqlSingle.Multiply(Test1, Test0).Value); try { SqlSingle test = SqlSingle.Multiply(TestMax, Test1); Assert.False(true); } catch (Exception e) { Assert.Equal(typeof(OverflowException), e.GetType()); } // Subtract() Assert.Equal((float)(-5E+30), SqlSingle.Subtract(Test1, Test3).Value); try { SqlSingle test = SqlSingle.Subtract( SqlSingle.MinValue, SqlSingle.MaxValue); Assert.False(true); } catch (Exception e) { Assert.Equal(typeof(OverflowException), e.GetType()); } }