public void GetHashCodeTest() { Half target = 777; int expected = 25106; int actual = target.GetHashCode(); Assert.Equal(expected, actual); }
public override int GetHashCode() { var hashCode = 1173473123; hashCode = hashCode * -1521134295 + min.GetHashCode(); hashCode = hashCode * -1521134295 + Min.GetHashCode(); hashCode = hashCode * -1521134295 + max.GetHashCode(); hashCode = hashCode * -1521134295 + Max.GetHashCode(); hashCode = hashCode * -1521134295 + current.GetHashCode(); hashCode = hashCode * -1521134295 + Current.GetHashCode(); hashCode = hashCode * -1521134295 + IsMax.GetHashCode(); hashCode = hashCode * -1521134295 + IsMin.GetHashCode(); hashCode = hashCode * -1521134295 + Rest.GetHashCode(); hashCode = hashCode * -1521134295 + Quarter.GetHashCode(); hashCode = hashCode * -1521134295 + Half.GetHashCode(); hashCode = hashCode * -1521134295 + Three_Fourths.GetHashCode(); hashCode = hashCode * -1521134295 + One_Third.GetHashCode(); return(hashCode); }
public static void Equals(Half value, object obj, bool expected) { if (obj is Half other) { Assert.Equal(expected, value.Equals(other)); if (Half.IsNaN(value) && Half.IsNaN(other)) { Assert.Equal(!expected, value == other); Assert.Equal(expected, value != other); } else { Assert.Equal(expected, value == other); Assert.Equal(!expected, value != other); } Assert.Equal(expected, value.GetHashCode().Equals(other.GetHashCode())); } Assert.Equal(expected, value.Equals(obj)); }
/// <summary> /// Returns the hash code for the current <see cref="Vector2h"/>. /// </summary> /// <returns>A 32-bit signed integer hash code.</returns> public override int GetHashCode() { return(X.GetHashCode() + Y.GetHashCode()); }