Esempio n. 1
0
 public static void EqualsTest(UInt128 i1, object obj, bool expected)
 {
     if (obj is UInt128 i2)
     {
         Assert.Equal(expected, i1.Equals(i2));
         Assert.Equal(expected, i1.GetHashCode().Equals(i2.GetHashCode()));
     }
     Assert.Equal(expected, i1.Equals(obj));
 }
Esempio n. 2
0
        public void UInt128_Equals_UInt128_Inequivalent_ReturnsFalse()
        {
            var baseValue = new UInt128()
            {
                High = 1, Low = 2
            };

            var testValues = new[] {
                new UInt128()
                {
                    Low = 2
                },
                new UInt128()
                {
                    High = 1
                },
            };


            foreach (var testValue in testValues)
            {
                Assert.False(
                    baseValue.Equals(testValue));
            }
        }
Esempio n. 3
0
        public void BinaryStringToUInt128Test2()
        {
            var a   = UInt128.FromBinaryString("11110101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101");
            var abi = a.ToBigInteger;

            var bbi = BigInteger.Parse("326103934965899360819067332122111202645");
            var b   = UInt128.FromBigInteger(bbi);

            Assert.IsTrue(UInt128.Equals(a, b));
            Assert.AreEqual(bbi, abi);
        }
        public void UInt128_Equals_Equivalent_ReturnsTrue()
        {
            var baseValue = new UInt128() { High = 1, Low = 2 };

            var testValues = new object[] { 
                baseValue, 
                new UInt128() { High = 1, Low = 2 } 
            };

            foreach (var testValue in testValues)
            {
                Assert.True(
                    baseValue.Equals(testValue));
            }
        }
Esempio n. 5
0
            public void UInt128_Equals_Works()
            {
                UInt128_Equality_Test(
                    (a, b) =>
                    a.Equals(b));


                var baseValue       = new UInt128();
                var falseTestValues = new object[] { null, "" };

                foreach (var falseTestValue in falseTestValues)
                {
                    Assert.False(
                        baseValue.Equals(falseTestValue));
                }
            }
        protected Func <bool> GetIdComparer(IRow r1, IRow r2, out ValueGetter <UInt128> idGetter)
        {
            var g1 = r1.GetIdGetter();

            idGetter = g1;
            var     g2 = r2.GetIdGetter();
            UInt128 v1 = default(UInt128);
            UInt128 v2 = default(UInt128);

            return
                (() =>
            {
                g1(ref v1);
                g2(ref v2);
                return v1.Equals(v2);
            });
        }
        public void UInt128_Equals_Inequivalent_ReturnsFalse()
        {
            var baseValue = new UInt128() { High = 1, Low = 2 };

            var testValues = new object[] {
                null, 
                "", 
                new UInt128() { Low = 2 }, 
                new UInt128 { High = 1 } 
            };

            
            foreach (var testValue in testValues)
            {
                Assert.False(
                    baseValue.Equals(testValue));
            }
        }
Esempio n. 8
0
        public void UInt128Equality()
        {
            UInt128 zero = UInt128.Zero;
            UInt128 one  = UInt128.One;
            UInt128 m    = UInt64.MaxValue;
            UInt128 n    = m + 1;

            Assert.IsTrue(UInt128.MinValue == UInt128.Zero);
            Assert.IsTrue(UInt128.Equals(UInt128.MaxValue, UInt128.MaxValue));
            Assert.IsTrue(UInt128.One.Equals((object)UInt128.One));

            Assert.IsTrue(zero != one);
            Assert.IsTrue(!one.Equals(zero));

            Assert.IsTrue(m + one == n);
            Assert.IsTrue(n.Equals(m + one));
            Assert.IsTrue(!m.Equals(null));
            Assert.IsTrue((m + one).GetHashCode() == n.GetHashCode());
        }
Esempio n. 9
0
        public void UInt128_Equals_Equivalent_ReturnsTrue()
        {
            var baseValue = new UInt128()
            {
                High = 1, Low = 2
            };

            var testValues = new object[] {
                baseValue,
                new UInt128()
                {
                    High = 1, Low = 2
                }
            };

            foreach (var testValue in testValues)
            {
                Assert.True(
                    baseValue.Equals(testValue));
            }
        }
Esempio n. 10
0
 public bool Equals(UInt128 other)
 {
     return(!IsNegative && v.Equals(other));
 }
Esempio n. 11
0
 public override bool Equals(object key)
 {
     return(p.Equals(((HASH_KEY)key).p));
 }