public void TestGetHashCode() { { Vector2 a = new Vector2(10, 11); Vector2 b = new Vector2(10, 11); Assert.IsTrue(a.GetHashCode() == b.GetHashCode()); } { Vector3 a = new Vector3(10, 11, 12); Vector3 b = new Vector3(10, 11, 12); Assert.IsTrue(a.GetHashCode() == b.GetHashCode()); } { Vector4 a = new Vector4(10, 11, 12, 13); Vector4 b = new Vector4(10, 11, 12, 13); Assert.IsTrue(a.GetHashCode() == b.GetHashCode()); } { Quaternion a = new Quaternion(10, 11, 12, 13); Quaternion b = new Quaternion(10, 11, 12, 13); Assert.IsTrue(a.GetHashCode() == b.GetHashCode()); } { Matrix4X4 a = Matrix4X4.CreateRotationX(3); Matrix4X4 b = Matrix4X4.CreateRotationX(3); Assert.IsTrue(a.GetHashCode() == b.GetHashCode()); } }
public void Test_Equals() { var a = new Vector3 (1, 2, 3.00001f); var b = new Vector3 (1, 2, 3.00002f); Assert.IsTrue (a.Equals (b)); // 誤差を許容する比較 Assert.IsFalse (a == b); // 厳密な比較 Assert.AreNotEqual (a.GetHashCode (), b.GetHashCode ()); // ハッシュは厳密な比較を基準 }
public void HashCode_CanDetermineTheHashCodeForAVector() { var vector = new Vector3(1.0, 2.0, 3.0); var hashCode = vector.GetHashCode(); Assert.AreEqual(118590513, hashCode); }
public void Vector3GetHashCodeTest() { Vector3 target = new Vector3(1.0f, 2.0f, 3.0f); int expected = target.X.GetHashCode() + target.Y.GetHashCode() + target.Z.GetHashCode(); int actual; actual = target.GetHashCode(); Assert.AreEqual(expected, actual, "Vector3.GetHashCode did not return the expected value."); }
public static void Test_Vector3_Generic_Expected_Hash_Code_Against_Unity3D(float a, float b, float c) { //arrange Vector3<float> genericVec = new Vector3<float>(a, b, c); UnityEngine.Vector3 unityVec = new UnityEngine.Vector3(a, b, c); //assert Assert.AreEqual(genericVec.GetHashCode(), unityVec.GetHashCode()); }