public void CombineHashCodes() { Assert.AreEqual(76781240, HashCodeUtility.CombineHashCodes(0)); Assert.AreEqual(1923623579, HashCodeUtility.CombineHashCodes(1)); Assert.AreEqual(76781240, HashCodeUtility.CombineHashCodes(new[] { 0 })); Assert.AreEqual(1489077439, HashCodeUtility.CombineHashCodes(0, 0)); Assert.AreEqual(-1105120207, HashCodeUtility.CombineHashCodes(0, 1)); Assert.AreEqual(1489077439, HashCodeUtility.CombineHashCodes(new[] { 0, 0 })); Assert.AreEqual(459859287, HashCodeUtility.CombineHashCodes(0, 0, 0)); Assert.AreEqual(-935278042, HashCodeUtility.CombineHashCodes(0, 0, 1)); Assert.AreEqual(459859287, HashCodeUtility.CombineHashCodes(new[] { 0, 0, 0 })); Assert.AreEqual(-1158084724, HashCodeUtility.CombineHashCodes(0, 0, 0, 0)); Assert.AreEqual(1498382024, HashCodeUtility.CombineHashCodes(0, 0, 0, 1)); Assert.AreEqual(-1158084724, HashCodeUtility.CombineHashCodes(new[] { 0, 0, 0, 0 })); Assert.AreEqual(1762635120, HashCodeUtility.CombineHashCodes(0, 0, 0, 0, 0)); Assert.AreEqual(951675744, HashCodeUtility.CombineHashCodes(0, 0, 0, 0, 1)); Assert.AreEqual(1762635120, HashCodeUtility.CombineHashCodes(new[] { 0, 0, 0, 0, 0 })); Assert.AreEqual(1002546726, HashCodeUtility.CombineHashCodes(0, 0, 0, 0, 0, 0)); Assert.AreEqual(-1323428179, HashCodeUtility.CombineHashCodes(0, 0, 0, 0, 0, 1)); Assert.AreEqual(1002546726, HashCodeUtility.CombineHashCodes(new[] { 0, 0, 0, 0, 0, 0 })); Assert.AreEqual(-1222849262, HashCodeUtility.CombineHashCodes(0, 0, 0, 0, 0, 0, 0)); Assert.AreEqual(1531490892, HashCodeUtility.CombineHashCodes(0, 0, 0, 0, 0, 0, 1)); Assert.AreEqual(-1222849262, HashCodeUtility.CombineHashCodes(new[] { 0, 0, 0, 0, 0, 0, 0 })); }
public override int GetHashCode() { return(HashCodeUtility.Combine( EqualityComparer <T> .Default.GetHashCode(Value), EqualityComparer <T2> .Default.GetHashCode(Value2) )); }
private static string GetHashPostfix(string originalName) { // return a persistant hash code so that the code stays stable // and comparable between different compiler versions. // also 4 characters should suffice. return("_" + Math.Abs(HashCodeUtility.GetPersistentHashCode(originalName)) .ToString("0000").Substring(0, 4)); }
public void CombineHashCodesDuplicate() { // test for bad hash code generation const string str = "happy"; Assert.AreNotEqual(0, HashCodeUtility.CombineHashCodes(str.GetHashCode(), str.GetHashCode())); Assert.AreNotEqual(str.GetHashCode(), HashCodeUtility.CombineHashCodes(str.GetHashCode(), str.GetHashCode())); }
public void GetPersistentIntHashCode(int nValue, int nExpected) { Assert.AreEqual(nExpected, HashCodeUtility.GetPersistentHashCode((sbyte)nValue)); Assert.AreEqual(nExpected, HashCodeUtility.GetPersistentHashCode((short)nValue)); if (nValue >= 0) { Assert.AreEqual(nExpected, HashCodeUtility.GetPersistentHashCode((char)nValue)); } Assert.AreEqual(nExpected, HashCodeUtility.GetPersistentHashCode(nValue)); }
public void GetPersistentIntHashCode(int value, int expected) { Assert.That(HashCodeUtility.GetPersistentHashCode((sbyte)value), Is.EqualTo(expected)); Assert.That(HashCodeUtility.GetPersistentHashCode((short)value), Is.EqualTo(expected)); if (value >= 0) { Assert.That(HashCodeUtility.GetPersistentHashCode((char)value), Is.EqualTo(expected)); } Assert.That(HashCodeUtility.GetPersistentHashCode(value), Is.EqualTo(expected)); }
/// <summary> /// Returns the hash code for this instance. /// </summary> /// <returns> /// A 32-bit signed integer hash code. /// </returns> /// <filterpriority>2</filterpriority> public override int GetHashCode() { unchecked { HashCodeUtility codeUtility = new HashCodeUtility(); codeUtility.AddObject(this.Name.ToLowerInvariant()); codeUtility.AddObject(this.InjectedType); int result = codeUtility.CombinedHash32; return(result); } }
public void Should_generate_from_relative_uri() { var report = new ErrorReportEntity(1, "kffk", DateTime.UtcNow, new ErrorReportException(), new[] { new ErrorReportContextCollection("Yadayada", new Dictionary <string, string> { { "Url", "/some/path?hada=yada" }, { "HttpCode", "404" } }) }); var sut = new HttpErrorGenerator(); var code = sut.GenerateHashCode(report); var source = $"404;/some/path"; code.HashCode.Should().Be(HashCodeUtility.GetPersistentHashCode(source).ToString("X")); }
public void CombineHashCodesNull() { HashCodeUtility.CombineHashCodes(null); }
public override int GetHashCode() { return(HashCodeUtility.GetHashCode(Full)); }
public override int GetHashCode() { return(HashCodeUtility.GetHashCode(Length, OpCode)); }
public void GetPersistentLongHashCode(long nValue, int nExpected) { Assert.AreEqual(nExpected, HashCodeUtility.GetPersistentHashCode(nValue)); }
public void GetPersistentBoolHashCode(bool value, int expected) { Assert.AreEqual(expected, HashCodeUtility.GetPersistentHashCode(value)); }
public void HashOne(int value) { Assert.That(HashCodeUtility.CombineHashCodes(value), Is.EqualTo(HashCodeUtility.CombineHashCodes(new[] { value }))); }
public override int GetHashCode() { return(unchecked (_rawData.Aggregate(0, (acc, b) => acc + HashCodeUtility.GetHashCode(b)))); }
/// <summary> /// Returns a hash code for the current object. /// </summary> /// <returns>A hash code for the current object.</returns> public override int GetHashCode() { // combine the hash codes of the various components of this class return(HashCodeUtility.CombineHashCodes(ObjectUtility.GetHashCode(m_text), m_count)); }
public override int GetHashCode() { return(unchecked (Family.GetHashCode() + _upperBoundary.Aggregate(0, (acc, b) => acc + HashCodeUtility.GetHashCode(b)) + _lowerBoundary.Aggregate(0, (acc, b) => acc + HashCodeUtility.GetHashCode(b)))); }
public override int GetHashCode() { return(HashCodeUtility.Combine(_identifiers.Select(i => i.GetHashCode()))); }
public void GetPersistentHash(string value, int expected) { Assert.That(HashCodeUtility.GetPersistentHashCode(value), Is.EqualTo(expected)); }
public void HashFour(int value1, int value2, int value3, int value4) { Assert.That(HashCodeUtility.CombineHashCodes(value1, value2, value3, value4), Is.EqualTo(HashCodeUtility.CombineHashCodes(new[] { value1, value2, value3, value4 }))); }
public void HashThree(int value1, int value2, int value3) { Assert.That(HashCodeUtility.CombineHashCodes(value1, value2, value3), Is.EqualTo(HashCodeUtility.CombineHashCodes(new[] { value1, value2, value3 }))); }
public void HashTwo(int value1, int value2) { Assert.That(HashCodeUtility.CombineHashCodes(value1, value2), Is.EqualTo(HashCodeUtility.CombineHashCodes(new[] { value1, value2 }))); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data /// structures like a hash table. /// </returns> /// ------------------------------------------------------------------------------------ public override int GetHashCode() { return(HashCodeUtility.CombineHashCodes(m_startRef.BBCCCVVV, m_endRef.BBCCCVVV, Text.GetHashCode(), TextStartIndex, TextLength, VerseStartIndex, Para.Hvo)); }
public override int GetHashCode() { return(HashCodeUtility.GetHashCode(Byte, SByte, UInt16, Int16, UInt32, Int32, UInt64, Int64, Char, Single, Double, Decimal)); }
public override int GetHashCode() { return(HashCodeUtility.CombineHashCodes(m_first, m_second, m_third)); }
public override int GetHashCode() { return(HashCodeUtility.CombineHashCodes(AttackerActionId.GetHashCode(), DefenderActionId.GetHashCode())); }