A game about forced loneliness, made by TACStudios
at master 2.2 kB view raw
1using System; 2using System.Collections.Generic; 3 4namespace UnityEngine.TestTools.Utils 5{ 6 /// <summary> 7 /// Use these classes to compare two objects of the same type for equality within the range of a given tolerance using NUnit or custom constraints . Call Instance to apply the default calculation error value to the comparison. 8 /// </summary> 9 public class Vector4ComparerWithEqualsOperator : IEqualityComparer<Vector4> 10 { 11 private static readonly Vector4ComparerWithEqualsOperator m_Instance = new Vector4ComparerWithEqualsOperator(); 12 /// <summary> 13 /// A singleton instance of the comparer with a predefined default error value. 14 /// </summary> 15 public static Vector4ComparerWithEqualsOperator Instance { get { return m_Instance; } } 16 17 private Vector4ComparerWithEqualsOperator() {} 18 /// <summary> 19 /// Compares the actual and expected objects for equality using a custom comparison mechanism. 20 /// </summary> 21 /// <param name="expected">Expected Vector4 used to compare</param> 22 /// <param name="actual">Actual Vector4 value to test.</param> 23 /// <returns>Returns true if expected and actual objects are equal, otherwise it returns false.</returns> 24 /// <example> 25 /// <code> 26 /// [TestFixture] 27 /// public class Vector4Test 28 /// { 29 /// [Test] 30 /// public void VerifyThat_TwoVector4ObjectsAreEqual() 31 /// { 32 /// var actual = new Vector4(10e-7f, 10e-7f, 10e-7f, 10e-7f); 33 /// var expected = new Vector4(0f, 0f, 0f, 0f); 34 /// 35 /// Assert.That(actual, Is.EqualTo(expected).Using(Vector4ComparerWithEqualsOperator.Instance)); 36 /// } 37 /// } 38 /// </code> 39 /// </example> 40 public bool Equals(Vector4 expected, Vector4 actual) 41 { 42 return expected == actual; 43 } 44 45 /// <summary> 46 /// Serves as the default hash function. 47 /// </summary> 48 /// <param name="vec4"> A not null Vector4 object</param> 49 /// <returns>Returns 0</returns> 50 public int GetHashCode(Vector4 vec4) 51 { 52 return 0; 53 } 54 } 55}