docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    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.

    Inheritance
    object
    Vector4ComparerWithEqualsOperator
    Implements
    IEqualityComparer<Vector4>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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

    Implements

    IEqualityComparer<T>
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)