Class Vector4ComparerWithEqualsOperator
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.
Implements
Inherited Members
Namespace: UnityEngine.TestTools.Utils
Assembly: UnityEngine.TestRunner.dll
Syntax
public class Vector4ComparerWithEqualsOperator : IEqualityComparer<Vector4>
Properties
Instance
A singleton instance of the comparer with a predefined default error value.
Declaration
public static Vector4ComparerWithEqualsOperator Instance { get; }
Property Value
Type | Description |
---|---|
Vector4ComparerWithEqualsOperator |
Methods
Equals(Vector4, Vector4)
Compares the actual and expected objects for equality using a custom comparison mechanism.
Declaration
public bool Equals(Vector4 expected, Vector4 actual)
Parameters
Type | Name | Description |
---|---|---|
Vector4 | expected | Expected Vector4 used to compare |
Vector4 | actual | Actual Vector4 value to test. |
Returns
Type | Description |
---|---|
bool | Returns true if expected and actual objects are equal, otherwise it returns false. |
Examples
[TestFixture]
public class Vector4Test
{
[Test]
public void VerifyThat_TwoVector4ObjectsAreEqual()
{
var actual = new Vector4(10e-7f, 10e-7f, 10e-7f, 10e-7f);
var expected = new Vector4(0f, 0f, 0f, 0f);
Assert.That(actual, Is.EqualTo(expected).Using(Vector4ComparerWithEqualsOperator.Instance));
}
}
GetHashCode(Vector4)
Serves as the default hash function.
Declaration
public int GetHashCode(Vector4 vec4)
Parameters
Type | Name | Description |
---|---|---|
Vector4 | vec4 | A not null Vector4 object |
Returns
Type | Description |
---|---|
int | Returns 0 |