public void Matrix3x2EqualsTest() { Matrix3x2 a = GenerateMatrixNumberFrom1To6(); Matrix3x2 b = GenerateMatrixNumberFrom1To6(); // case 1: compare between same values object obj = b; bool expected = true; bool actual = a.Equals(obj); Assert.Equal(expected, actual); // case 2: compare between different values b.M11 = 11.0f; obj = b; expected = false; actual = a.Equals(obj); Assert.Equal(expected, actual); // case 3: compare between different types. obj = new Vector4(); expected = false; actual = a.Equals(obj); Assert.Equal(expected, actual); // case 3: compare against null. obj = null; expected = false; actual = a.Equals(obj); Assert.Equal(expected, actual); }
public void Matrix3x2EqualsTest1() { Matrix3x2 a = GenerateMatrixNumberFrom1To6(); Matrix3x2 b = GenerateMatrixNumberFrom1To6(); // case 1: compare between same values bool expected = true; bool actual = a.Equals(b); Assert.Equal(expected, actual); // case 2: compare between different values b.M11 = 11.0f; expected = false; actual = a.Equals(b); Assert.Equal(expected, actual); }
public void Matrix3x2EqualsNanTest() { Matrix3x2 a = new Matrix3x2(Single.NaN, 0, 0, 0, 0, 0); Matrix3x2 b = new Matrix3x2(0, Single.NaN, 0, 0, 0, 0); Matrix3x2 c = new Matrix3x2(0, 0, Single.NaN, 0, 0, 0); Matrix3x2 d = new Matrix3x2(0, 0, 0, Single.NaN, 0, 0); Matrix3x2 e = new Matrix3x2(0, 0, 0, 0, Single.NaN, 0); Matrix3x2 f = new Matrix3x2(0, 0, 0, 0, 0, Single.NaN); Assert.False(a == new Matrix3x2()); Assert.False(b == new Matrix3x2()); Assert.False(c == new Matrix3x2()); Assert.False(d == new Matrix3x2()); Assert.False(e == new Matrix3x2()); Assert.False(f == new Matrix3x2()); Assert.True(a != new Matrix3x2()); Assert.True(b != new Matrix3x2()); Assert.True(c != new Matrix3x2()); Assert.True(d != new Matrix3x2()); Assert.True(e != new Matrix3x2()); Assert.True(f != new Matrix3x2()); Assert.False(a.Equals(new Matrix3x2())); Assert.False(b.Equals(new Matrix3x2())); Assert.False(c.Equals(new Matrix3x2())); Assert.False(d.Equals(new Matrix3x2())); Assert.False(e.Equals(new Matrix3x2())); Assert.False(f.Equals(new Matrix3x2())); Assert.False(a.IsIdentity); Assert.False(b.IsIdentity); Assert.False(c.IsIdentity); Assert.False(d.IsIdentity); Assert.False(e.IsIdentity); Assert.False(f.IsIdentity); // Counterintuitive result - IEEE rules for NaN comparison are weird! Assert.False(a.Equals(a)); Assert.False(b.Equals(b)); Assert.False(c.Equals(c)); Assert.False(d.Equals(d)); Assert.False(e.Equals(e)); Assert.False(f.Equals(f)); }