public unsafe void TestAllPossibleHalfValues() { for (ushort i = ushort.MinValue; i < ushort.MaxValue; i++) { Half half1 = Half.ToHalf(i); Half half2 = (Half)((float)half1); Assert.IsTrue(half1.Equals(half2)); } }
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)); }
public void EqualsTest() { { Half target = new Half(); object obj = new Single(); bool expected = false; bool actual = target.Equals(obj); Assert.Equal(expected, actual); } { Half target = new Half(); object obj = (Half)111; bool expected = false; bool actual = target.Equals(obj); Assert.Equal(expected, actual); } }
public void EqualsTest1() { { Half target = Half.MinValue; Half half = Half.MinValue; bool expected = true; bool actual = target.Equals(half); Assert.Equal(expected, actual); } { Half target = 12345; Half half = 12345; bool expected = true; bool actual = target.Equals(half); Assert.Equal(expected, actual); } }
public static void Equals(Half value, object obj, bool expected) { Assert.Equal(expected, value.Equals(obj)); }