docs.unity.cn
    Show / Hide Table of Contents

    Method AreEqual

    AreEqual<T>(T, T)

    Assert that two values are exactly equal to each other, according to their type's definition of equality. Throws an exception if the assertion fails.

    Declaration
    [Conditional("UNITY_ASSERTIONS")]
    public static void AreEqual<T>(T expected, T actual)
        where T : IEquatable<T>
    Parameters
    Type Name Description
    T expected

    The expected value.

    T actual

    The actual value.

    Type Parameters
    Name Description
    T

    The type of the values to test.

    AreEqual<T>(T, T, String)

    Assert that two values are exactly equal to each other, according to their type's definition of equality. Throws an exception if the assertion fails.

    Declaration
    [Conditional("UNITY_ASSERTIONS")]
    public static void AreEqual<T>(T expected, T actual, string message)
        where T : IEquatable<T>
    Parameters
    Type Name Description
    T expected

    The expected value.

    T actual

    The actual value.

    String message

    If the assertion fails, this message will be logged.

    Type Parameters
    Name Description
    T

    The type of the values to test.

    AreEqual(Int32, Int32)

    Assert that two 32-bit integer values are equal to each other. Throws an exception if the assertion fails.

    Declaration
    [Conditional("UNITY_ASSERTIONS")]
    public static void AreEqual(int expected, int actual)
    Parameters
    Type Name Description
    Int32 expected

    The expected value.

    Int32 actual

    The actual value.

    AreEqual(Boolean, Boolean)

    Assert that two boolean values are equal to each other. Throws an exception if the assertion fails.

    Declaration
    [Conditional("UNITY_ASSERTIONS")]
    public static void AreEqual(bool expected, bool actual)
    Parameters
    Type Name Description
    Boolean expected

    The expected value.

    Boolean actual

    The actual value.

    AreEqual(Type, Type)

    Assert that two boolean values are not equal to each other. Throws an exception if the assertion fails.

    Declaration
    [Conditional("UNITY_ASSERTIONS")]
    public static void AreEqual(Type expected, Type actual)
    Parameters
    Type Name Description
    Type expected

    The expected value.

    Type actual

    The actual value.

    AreEqual(IntPtr, IntPtr)

    Assert that two IntPtr values are equal to each other. Throws an exception if the assertion fails.

    Declaration
    [Conditional("UNITY_ASSERTIONS")]
    public static void AreEqual(IntPtr expected, IntPtr actual)
    Parameters
    Type Name Description
    IntPtr expected

    The expected value.

    IntPtr actual

    The actual value.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023