{!See https://docs.google.com/document/d/1takg_GmIBBKKTj-GHZCwzxohpQz7Bhekivkk72kYMtE/edit for reference implementation of OneTrust, dataLayer and GTM} {!OneTrust Cookies Consent} {!OneTrust Cookies Consent end} {!dataLayer initialization push} {!dataLayer initialization push end} {!Google Tag Manager} {!Google Tag Manager end} Custom equality comparers with equals operator | Test Framework | 1.0.18
docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Custom equality comparers with equals operator

    If you need to compare Vectors using the overloaded operator == (see Vector2.operator ==, Vector3.operator ==, and Vector4.operator ==) you should use the respective comparer implementations:

    • Vector2ComparerWithEqualsOperator
    • Vector3ComparerWithEqualsOperator
    • Vector4ComparerWithEqualsOperator

    The interface is the same as for other equality comparers except the public constructor error parameter is inapplicable in this case.

    Example

    [TestFixture]
    public class Vector3Test
    {
        [Test]
        public void VerifyThat_TwoVector3ObjectsAreEqual()
        {
            var actual = new Vector3(10e-7f, 10e-7f, 10e-7f);
            var expected = new Vector3(0f, 0f, 0f);
    
            Assert.That(actual, Is.EqualTo(expected).Using(Vector3ComparerWithEqualsOperator.Instance));
        }
    }
    
    In This Article
    Back to top
    Copyright © 2023 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)