docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Vector3ComparerWithEqualsOperator

    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
    Vector3ComparerWithEqualsOperator
    Implements
    IEqualityComparer<Vector3>
    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 Vector3ComparerWithEqualsOperator : IEqualityComparer<Vector3>

    Properties

    Instance

    A singleton instance of the comparer with a predefined default error value.

    Declaration
    public static Vector3ComparerWithEqualsOperator Instance { get; }
    Property Value
    Type Description
    Vector3ComparerWithEqualsOperator

    Methods

    Equals(Vector3, Vector3)

    Compares the actual and expected objects for equality using a custom comparison mechanism.

    Declaration
    public bool Equals(Vector3 expected, Vector3 actual)
    Parameters
    Type Name Description
    Vector3 expected

    Expected Vector3 used to compare

    Vector3 actual

    Actual Vector3 value to test.

    Returns
    Type Description
    bool

    Returns true if expected and actual objects are equal, otherwise it returns false.

    Examples
    [TestFixture]
    public class Vector3Test
    {
        [Test]
        public void VerifyThat_TwoVector3ObjectsAreEqual()
        {
            var actual = new Vector2(10e-7f, 10e-7f, 10e-7f);
            var expected = new Vector2(0f, 0f, 0f);
    
            Assert.That(actual, Is.EqualTo(expected).Using(Vector3ComparerWithEqualsOperator.Instance));
        }
    }

    GetHashCode(Vector3)

    Serves as the default hash function.

    Declaration
    public int GetHashCode(Vector3 vec3)
    Parameters
    Type Name Description
    Vector3 vec3

    A not null Vector3 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)