public void ArithmeticMethods() { SqlInt64 Test64 = new SqlInt64(64); SqlInt64 Test0 = new SqlInt64(0); SqlInt64 Test164 = new SqlInt64(164); SqlInt64 TestMax = new SqlInt64(SqlInt64.MaxValue.Value); // Add() Assert.AreEqual((long)64, SqlInt64.Add(Test64, Test0).Value, "#D01"); Assert.AreEqual((long)228, SqlInt64.Add(Test64, Test164).Value, "#D02"); Assert.AreEqual((long)164, SqlInt64.Add(Test0, Test164).Value, "#D03"); Assert.AreEqual((long)SqlInt64.MaxValue, SqlInt64.Add(TestMax, Test0).Value, "#D04"); try { SqlInt64.Add(TestMax, Test64); Assert.Fail("#D05"); } catch (OverflowException e) { Assert.AreEqual(typeof(OverflowException), e.GetType(), "#D06"); } // Divide() Assert.AreEqual((long)2, SqlInt64.Divide(Test164, Test64).Value, "#D07"); Assert.AreEqual((long)0, SqlInt64.Divide(Test64, Test164).Value, "#D08"); try { SqlInt64.Divide(Test64, Test0); Assert.Fail("#D09"); } catch (DivideByZeroException e) { Assert.AreEqual(typeof(DivideByZeroException), e.GetType(), "#D10"); } // Mod() Assert.AreEqual((SqlInt64)36, SqlInt64.Mod(Test164, Test64), "#D11"); Assert.AreEqual((SqlInt64)64, SqlInt64.Mod(Test64, Test164), "#D12"); // Multiply() Assert.AreEqual((long)10496, SqlInt64.Multiply(Test64, Test164).Value, "#D13"); Assert.AreEqual((long)0, SqlInt64.Multiply(Test64, Test0).Value, "#D14"); try { SqlInt64.Multiply(TestMax, Test64); Assert.Fail("#D15"); } catch (OverflowException e) { Assert.AreEqual(typeof(OverflowException), e.GetType(), "#D16"); } // Subtract() Assert.AreEqual((long)100, SqlInt64.Subtract(Test164, Test64).Value, "#D17"); try { SqlInt64.Subtract(SqlInt64.MinValue, Test164); Assert.Fail("#D18"); } catch (OverflowException e) { Assert.AreEqual(typeof(OverflowException), e.GetType(), "#D19"); } // Modulus () Assert.AreEqual((SqlInt64)36, SqlInt64.Modulus(Test164, Test64), "#D20"); Assert.AreEqual((SqlInt64)64, SqlInt64.Modulus(Test64, Test164), "#D21"); }
public void ArithmeticMethods() { SqlInt64 test64 = new SqlInt64(64); SqlInt64 test0 = new SqlInt64(0); SqlInt64 test164 = new SqlInt64(164); SqlInt64 testMax = new SqlInt64(SqlInt64.MaxValue.Value); // Add() Assert.Equal(64, SqlInt64.Add(test64, test0).Value); Assert.Equal(228, SqlInt64.Add(test64, test164).Value); Assert.Equal(164, SqlInt64.Add(test0, test164).Value); Assert.Equal((long)SqlInt64.MaxValue, SqlInt64.Add(testMax, test0).Value); Assert.Throws <OverflowException>(() => SqlInt64.Add(testMax, test64)); // Divide() Assert.Equal(2, SqlInt64.Divide(test164, test64).Value); Assert.Equal(0, SqlInt64.Divide(test64, test164).Value); Assert.Throws <DivideByZeroException>(() => SqlInt64.Divide(test64, test0)); // Mod() Assert.Equal(36, SqlInt64.Mod(test164, test64)); Assert.Equal(64, SqlInt64.Mod(test64, test164)); // Multiply() Assert.Equal(10496, SqlInt64.Multiply(test64, test164).Value); Assert.Equal(0, SqlInt64.Multiply(test64, test0).Value); Assert.Throws <OverflowException>(() => SqlInt64.Multiply(testMax, test64)); // Subtract() Assert.Equal(100, SqlInt64.Subtract(test164, test64).Value); Assert.Throws <OverflowException>(() => SqlInt64.Subtract(SqlInt64.MinValue, test164)); // Modulus () Assert.Equal(36, SqlInt64.Modulus(test164, test64)); Assert.Equal(64, SqlInt64.Modulus(test64, test164)); }
public void ArithmeticMethods() { SqlInt64 Test64 = new SqlInt64(64); SqlInt64 Test0 = new SqlInt64(0); SqlInt64 Test164 = new SqlInt64(164); SqlInt64 TestMax = new SqlInt64(SqlInt64.MaxValue.Value); // Add() Assert.Equal(64, SqlInt64.Add(Test64, Test0).Value); Assert.Equal(228, SqlInt64.Add(Test64, Test164).Value); Assert.Equal(164, SqlInt64.Add(Test0, Test164).Value); Assert.Equal((long)SqlInt64.MaxValue, SqlInt64.Add(TestMax, Test0).Value); try { SqlInt64.Add(TestMax, Test64); Assert.False(true); } catch (OverflowException e) { Assert.Equal(typeof(OverflowException), e.GetType()); } // Divide() Assert.Equal(2, SqlInt64.Divide(Test164, Test64).Value); Assert.Equal(0, SqlInt64.Divide(Test64, Test164).Value); try { SqlInt64.Divide(Test64, Test0); Assert.False(true); } catch (DivideByZeroException e) { Assert.Equal(typeof(DivideByZeroException), e.GetType()); } // Mod() Assert.Equal(36, SqlInt64.Mod(Test164, Test64)); Assert.Equal(64, SqlInt64.Mod(Test64, Test164)); // Multiply() Assert.Equal(10496, SqlInt64.Multiply(Test64, Test164).Value); Assert.Equal(0, SqlInt64.Multiply(Test64, Test0).Value); try { SqlInt64.Multiply(TestMax, Test64); Assert.False(true); } catch (OverflowException e) { Assert.Equal(typeof(OverflowException), e.GetType()); } // Subtract() Assert.Equal(100, SqlInt64.Subtract(Test164, Test64).Value); try { SqlInt64.Subtract(SqlInt64.MinValue, Test164); Assert.False(true); } catch (OverflowException e) { Assert.Equal(typeof(OverflowException), e.GetType()); } // Modulus () Assert.Equal(36, SqlInt64.Modulus(Test164, Test64)); Assert.Equal(64, SqlInt64.Modulus(Test64, Test164)); }