示例#1
0
 public void HashCodeInt(Integer value, int expected)
 {
     using (Immutability.Guard(value))
     {
         Assert.Equal(expected, value.GetHashCode());
     }
 }
        public void Log(Integer value, double baseValue, double expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.Log(baseValue);

                Assert.Equal(expected, actual, 8);
            }
        }
示例#3
0
        public void LessThan(Integer left, Integer right, bool expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actual = left < right;

                Assert.Equal(expected, actual);
            }
        }
        public void Pow(Integer value, int power, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.Pow(power);

                Assert.Equal(expected, actual);
            }
        }
        public void Sgn(Integer value, int expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.Sgn();

                Assert.Equal(expected, actual);
            }
        }
        public void ToByteArray(Integer value, byte[] expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.ToByteArray();

                Assert.Equal(expected, actual);
            }
        }
        public void Lcm(Integer left, Integer right, Integer expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actual = left.Lcm(right);

                Assert.Equal(expected, actual);
            }
        }
示例#8
0
        public void LessThanOrEqualInt(Integer left, int right, bool expected)
        {
            using (Immutability.Guard(left))
            {
                var actual = left <= right;

                Assert.Equal(expected, actual);
            }
        }
示例#9
0
        public void String(Integer value, string expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.ToString();

                Assert.Equal(expected, actual);
            }
        }
        public void Abs(Integer value, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = value.Abs();

                Assert.Equal(expected, actual);
            }
        }
示例#11
0
        public void GreaterThanOrEqual(Integer left, Integer right, bool expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actual = left >= right;

                Assert.Equal(expected, actual);
            }
        }
示例#12
0
        public void CastToInt64(Integer value, long expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = (long)value;

                Assert.Equal(expected, actual);
            }
        }
示例#13
0
        public void CastToInt32(Integer value, int expected)
        {
            using (Immutability.Guard(value))
            {
                var actual = (int)value;

                Assert.Equal(expected, actual);
            }
        }
示例#14
0
        public void NotEqualsInt(Integer left, int right, bool expected)
        {
            using (Immutability.Guard(left))
            {
                var actual = left != right;

                Assert.Equal(expected, actual);
            }
        }
示例#15
0
        public static void RemainderZero()
        {
            var value = (Integer)0;

            using (Immutability.Guard(value))
            {
                Assert.Throws <DivideByZeroException>(()
                                                      => value % value);
            }
        }
        public void ModPow(Integer value, Integer power, Integer modulus,
                           Integer expected)
        {
            using (Immutability.Guard(value, power, modulus))
            {
                var actual = value.ModPow(power, modulus);

                Assert.Equal(expected, actual);
            }
        }
        public static void PowInvalid()
        {
            var value = (Integer)0;

            using (Immutability.Guard(value))
            {
                Assert.Throws <ArgumentOutOfRangeException>(()
                                                            => value.Pow(-1));
            }
        }
示例#18
0
        public static void EqualsNullOrInvalid()
        {
            var value = (Integer)0;

            using (Immutability.Guard(value))
            {
                Assert.False(value.Equals(null));
                Assert.False(value.Equals(""));
            }
        }
示例#19
0
        public void Remainder(Integer left, Integer right, Integer expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actualOp = left % right;
                var actualFu = left.Remainder(right);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
示例#20
0
        public void Divide(Integer left, Integer right, Integer expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actualOp = left / right;
                var actualFu = left.Divide(right);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
示例#21
0
        public void Multiply(Integer left, Integer right, Integer expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actualOp = left * right;
                var actualFu = left.Multiply(right);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
示例#22
0
        public void Square(Integer value, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actualOp = value * value;
                var actualFu = value.Multiply(value);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
示例#23
0
        public void SubtractInt(Integer left, int right, Integer expected)
        {
            using (Immutability.Guard(left))
            {
                var actualOp = left - right;
                var actualFu = left.Subtract(right);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
示例#24
0
        public void Decrement(Integer value, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actualOp = value; --actualOp;
                var actualFu = value.Decrement();

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
示例#25
0
        public void LeftShift(Integer value, int shift, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actualOp = value << shift;
                var actualFu = value.LeftShift(shift);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
示例#26
0
        public void CompareTo(Integer left, Integer right, int expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actual    = left.CompareTo(right);
                var actualObj = left.CompareTo((object)right);

                Assert.Equal(expected, actual);
                Assert.Equal(expected, actualObj);
            }
        }
示例#27
0
        public void Negate(Integer value, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actualOp = -value;
                var actualFu = value.Negate();

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
示例#28
0
        public void OnesComplement(Integer value, Integer expected)
        {
            using (Immutability.Guard(value))
            {
                var actualOp = ~value;
                var actualFu = value.OnesComplement();

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
示例#29
0
        public void BitwiseAnd(Integer left, Integer right, Integer expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actualOp = left & right;
                var actualFu = left.BitwiseAnd(right);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
            }
        }
        public static void DivRemInvalid()
        {
            var value = (Integer)0;

            using (Immutability.Guard(value))
            {
                var remainder = default(Integer);
                Assert.Throws <DivideByZeroException>(()
                                                      => value.DivRem(0, out remainder));
            }
        }