示例#1
0
        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));
            }
        }
示例#2
0
        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));
        }
示例#3
0
 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);
     }
 }
示例#4
0
 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);
     }
 }
示例#5
0
 public static void Equals(Half value, object obj, bool expected)
 {
     Assert.Equal(expected, value.Equals(obj));
 }