Esempio n. 1
0
    public static void TestGetHashCode()
    {
        sbyte i1 = 123;
        sbyte i2 = 65;

        Assert.NotEqual(0, i1.GetHashCode());
        Assert.NotEqual(i1.GetHashCode(), i2.GetHashCode());
    }
Esempio n. 2
0
        public void Equals()
        {
            SByteTestData[] testData = new SByteTestData[]
            {
                new SByteTestData((sbyte)78, (sbyte)78, true),
                new SByteTestData((sbyte)78, (sbyte)-78, false),
                new SByteTestData((sbyte)78, (sbyte)0, false),
                new SByteTestData((sbyte)0, (sbyte)0, true),
                new SByteTestData((sbyte)-78, (sbyte)-78, true),
                new SByteTestData((sbyte)-78, (sbyte)78, false),
                new SByteTestData((sbyte)78, null, false),
                new SByteTestData((sbyte)78, "78", false),
                new SByteTestData((sbyte)78, 78, false)
            };

            foreach (var test in testData)
            {
                if (test.Obj is sbyte)
                {
                    sbyte i2 = (sbyte)test.Obj;
                    Assert.Equal(test.Expected, test.B.Equals(i2));
                    Assert.Equal(test.Expected, test.B.GetHashCode().Equals(i2.GetHashCode()));
                }

                Assert.Equal(test.Expected, test.B.Equals(test.Obj));
            }
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (SampleString != null ? SampleString.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ SampleInt8.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleInt16.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleInt32;
         hashCode = (hashCode * 397) ^ SampleInt64.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleUInt8.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleUInt16.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)SampleUInt32;
         hashCode = (hashCode * 397) ^ SampleUInt64.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleFloat.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleDouble.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleDecimal.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleBool.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleDateTime.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleTimeSpan.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)SampleEnum;
         hashCode = (hashCode * 397) ^ (int)SampleFlagEnum;
         hashCode = (hashCode * 397) ^ SampleNullableUInt32.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 4
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((m_WriteEnabled.GetHashCode() * 397) ^ m_CompareFunction.GetHashCode());
     }
 }
Esempio n. 5
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((_encodedValue.GetHashCode() * 397) ^ _length.GetHashCode());
     }
 }
Esempio n. 6
0
        public override int GetHashCode()
        {
            var hashCode = 1861411795;

            hashCode = hashCode * -1521134295 + X.GetHashCode();
            hashCode = hashCode * -1521134295 + Y.GetHashCode();
            return(hashCode);
        }
Esempio n. 7
0
        /// <summary>Generates the hash code for this object</summary>
        public override int GetHashCode()
        {
            int hashCode = 1502939027;

            hashCode = hashCode * -1521134295 + x.GetHashCode();
            hashCode = hashCode * -1521134295 + y.GetHashCode();
            return(hashCode);
        }
 public override int GetHashCode()
 {
     unchecked {
         int hashCode = _horizontalValue.GetHashCode();
         hashCode = (hashCode * 397) ^ _verticalValue.GetHashCode();
         hashCode = (hashCode * 397) ^ (_bits != null ? _bits.GetHashCode() : 0);
         return(hashCode);
     }
 }
Esempio n. 9
0
 public static void EqualsTest(sbyte i1, object obj, bool expected)
 {
     if (obj is sbyte)
     {
         sbyte i2 = (sbyte)obj;
         Assert.Equal(expected, i1.Equals(i2));
         Assert.Equal(expected, i1.GetHashCode().Equals(i2.GetHashCode()));
     }
     Assert.Equal(expected, i1.Equals(obj));
 }
Esempio n. 10
0
        static void Main(string[] args)
        {
            Utility.Inizia();

            byte v1 = new byte();

            v1 = 10;
            Console.WriteLine("{0,-16:X}|{1}|{2}", v1.GetHashCode(), v1.GetType(), v1.GetTypeCode());

            sbyte v2 = new sbyte();

            v2 = 11;
            Console.WriteLine("{0,-16:X}|{1}|{2}", v2.GetHashCode(), v2.GetType(), v2.GetTypeCode());

            short v3 = new short();

            v3 = 12;
            Console.WriteLine("{0,-16:X}|{1}|{2}", v3.GetHashCode(), v3.GetType(), v3.GetTypeCode());

            ushort v4 = new ushort();

            v4 = 13;
            Console.WriteLine("{0,-16:X}|{1}|{2}", v4.GetHashCode(), v4.GetType(), v4.GetTypeCode());

            float v5 = new float();

            v5 = 14.0F;
            Console.WriteLine("{0,-16:X}|{1}|{2}", v5.GetHashCode(), v5.GetType(), v5.GetTypeCode());

            double v6 = new double();

            v6 = 14.0D;
            Console.WriteLine("{0,-16:X}|{1}|{2}", v6.GetHashCode(), v6.GetType(), v6.GetTypeCode());

            decimal v7 = new decimal();

            v7 = 15.0M;
            Console.WriteLine("{0,-16:X}|{1}|{2}", v7.GetHashCode(), v7.GetType(), v7.GetTypeCode());

            Console.WriteLine("The size of sbyte   is {0}.", sizeof(sbyte));
            Console.WriteLine("The size of byte    is {0}.", sizeof(byte));
            Console.WriteLine("The size of short   is {0}.", sizeof(short));
            Console.WriteLine("The size of ushort  is {0}.", sizeof(ushort));
            Console.WriteLine("The size of int     is {0}.", sizeof(int));
            Console.WriteLine("The size of uint    is {0}.", sizeof(uint));
            Console.WriteLine("The size of long    is {0}.", sizeof(long));
            Console.WriteLine("The size of ulong   is {0}.", sizeof(ulong));
            Console.WriteLine("The size of char    is {0}.", sizeof(char));
            Console.WriteLine("The size of float   is {0}.", sizeof(float));
            Console.WriteLine("The size of double  is {0}.", sizeof(double));
            Console.WriteLine("The size of decimal is {0}.", sizeof(decimal));
            Console.WriteLine("The size of bool    is {0}.", sizeof(bool));

            Utility.Ferma();
        }
Esempio n. 11
0
        public override int GetHashCode()
        {
            var hash = 13;

            hash = hash * 7 + offsetX.GetHashCode();
            hash = hash * 7 + offsetY.GetHashCode();
            hash = hash * 7 + glyphWidth.GetHashCode();
            hash = hash * 7 + glyphHeight.GetHashCode();

            return(hash);
        }
Esempio n. 12
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 47;
         hash = hash * 227 + x.GetHashCode();
         hash = hash * 227 + y.GetHashCode();
         hash = hash * 227 + z.GetHashCode();
         return(hash);
     }
 }
Esempio n. 13
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = ID.GetHashCode();
         hashCode = (hashCode * 397) ^ Damage.GetHashCode();
         hashCode = (hashCode * 397) ^ Count.GetHashCode();
         //hashCode = (hashCode * 397) ^ Slot.GetHashCode();
         hashCode = (hashCode * 397) ^ (NBTData != null ? NBTData.GetHashCode() : 0);
         return(hashCode);
     }
 }
Esempio n. 14
0
            public void SbyteequalityComparerViaBuilder()
            {
                SCG.IEqualityComparer <sbyte> h = C5.EqualityComparer <sbyte> .Default;
                sbyte s = 3;
                sbyte t = 3;
                sbyte u = -5;

                Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
                Assert.IsTrue(h.Equals(s, t));
                Assert.IsFalse(h.Equals(s, u));
                Assert.AreSame(h, C5.EqualityComparer <sbyte> .Default);
            }
Esempio n. 15
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = сonfidentialityViolation.GetHashCode();
         hashCode = (hashCode * 397) ^ integrityViolation.GetHashCode();
         hashCode = (hashCode * 397) ^ availabilityViolation.GetHashCode();
         hashCode = (hashCode * 397) ^ (Id != null ? Id.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SourceOfThreat != null ? SourceOfThreat.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ObjectOfImpact != null ? ObjectOfImpact.GetHashCode() : 0);
         return(hashCode);
     }
 }
Esempio n. 16
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = SByte.GetHashCode();
         hashCode = (hashCode * 397) ^ Byte.GetHashCode();
         hashCode = (hashCode * 397) ^ Int16.GetHashCode();
         hashCode = (hashCode * 397) ^ UInt16.GetHashCode();
         hashCode = (hashCode * 397) ^ Int32;
         hashCode = (hashCode * 397) ^ (int)UInt32;
         hashCode = (hashCode * 397) ^ Int64.GetHashCode();
         hashCode = (hashCode * 397) ^ UInt64.GetHashCode();
         hashCode = (hashCode * 397) ^ Single.GetHashCode();
         hashCode = (hashCode * 397) ^ Double.GetHashCode();
         hashCode = (hashCode * 397) ^ Decimal.GetHashCode();
         hashCode = (hashCode * 397) ^ Char.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 17
0
 public override int GetHashCode() =>
 _boolValue.GetHashCode()
 ^ _sbyteValue.GetHashCode()
 ^ _byteValue.GetHashCode()
 ^ _int16Value.GetHashCode()
 ^ _uint16Value.GetHashCode()
 ^ _int32Value.GetHashCode()
 ^ _uint32Value.GetHashCode()
 ^ _int64Value.GetHashCode()
 ^ _uint64Value.GetHashCode()
 ^ _floatValue.GetHashCode()
 ^ _doubleValue.GetHashCode()
 ^ _stringValue.GetHashCode()
 ^ _intArray.GetHashCode()
 ^ _intList.GetHashCode()
 ^ _dict.GetHashCode()
 ^ _child.GetHashCode()
 ^ _children.GetHashCode()
 ^ _readonlyIntValue.GetHashCode()
 ;
Esempio n. 18
0
    public bool PosTest5()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest5: Return the random sbyte hashcode 2");
        try
        {
            sbyte sourceVal   = (sbyte)(this.GetInt32(1, 129) * (-1));
            int   retHashCode = sourceVal.GetHashCode();
            if (retHashCode != midVal2 * (int)(sourceVal) * (-1))
            {
                TestLibrary.TestFramework.LogError("009", "the ExpectResult is not the ActualResult");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("010", "Unexpect exception:" + e);
            retVal = false;
        }
        return(retVal);
    }
Esempio n. 19
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Return the SByte MinValue hashcode");
        try
        {
            sbyte sourceVal   = sbyte.MinValue;
            int   retHashCode = sourceVal.GetHashCode();
            if (retHashCode != midVal2 * (int)sbyte.MinValue * (-1))
            {
                TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
            retVal = false;
        }
        return(retVal);
    }
Esempio n. 20
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Return the 0 hashcode");
        try
        {
            sbyte sourceVal   = 0;
            int   retHashCode = sourceVal.GetHashCode();
            if (retHashCode != 0)
            {
                TestLibrary.TestFramework.LogError("005", "the ExpectResult is not the ActualResult");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpect exception:" + e);
            retVal = false;
        }
        return(retVal);
    }
Esempio n. 21
0
 public override int GetHashOfValue()
 {
     return(value.GetHashCode());
 }
Esempio n. 22
0
 /// <summary>
 /// Returns the hash code for the current <see cref="Vector2sb"/>.
 /// </summary>
 /// <returns>A 32-bit signed integer hash code.</returns>
 public override int GetHashCode()
 {
     return(X.GetHashCode() + Y.GetHashCode());
 }
Esempio n. 23
0
 public override int GetHashCode()
 {
     unchecked {
         return((RowDelta.GetHashCode() * 397) ^ ColDelta.GetHashCode());
     }
 }
 public override int GetHashCode()
 {
     return(this.GetType().FullName.GetHashCode() ^ Type.GetHashCode() ^ Window.GetHashCode() ^ SendEvent.GetHashCode() ^ Time.GetHashCode() ^ Group.GetHashCode() ^ Button.GetHashCode() ^ Mode.GetHashCode());
 }
 public override int GetHashCode()
 {
     return(this.GetType().FullName.GetHashCode() ^ Type.GetHashCode() ^ Window.GetHashCode() ^ SendEvent.GetHashCode() ^ Phase.GetHashCode() ^ NFingers.GetHashCode() ^ Time.GetHashCode() ^ X.GetHashCode() ^ Y.GetHashCode() ^ Dx.GetHashCode() ^ Dy.GetHashCode() ^ XRoot.GetHashCode() ^ YRoot.GetHashCode() ^ State.GetHashCode());
 }
Esempio n. 26
0
 public override int GetHashCode()
 {
     // ReSharper disable once ImpureMethodCallOnReadonlyValueField
     return(_value.GetHashCode());
 }
Esempio n. 27
0
 public override int GetHashCode() => b.GetHashCode();
Esempio n. 28
0
 internal static int GetSafeHash(this sbyte value) => value.GetHashCode();
Esempio n. 29
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     return(-1939223833 + _value.GetHashCode());
 }
Esempio n. 30
0
 /// <summary>
 /// Returns the hash code for the current <see cref="Vector8sb"/>.
 /// </summary>
 /// <returns>A 32-bit signed integer hash code.</returns>
 public override int GetHashCode()
 {
     return(V0.GetHashCode() + V1.GetHashCode() + V2.GetHashCode() + V3.GetHashCode() + V4.GetHashCode() + V5.GetHashCode() + V6.GetHashCode() + V7.GetHashCode());
 }