bool
如果预期对象与实际对象相等,则返回 true
,否则返回 false
。
比较“实际”和“预期”Vector3 对象的相等性。
如示例所示,在与约束共同使用时,此方法将被 NUnit
调用。
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools.Utils;
[TestFixture]
public class Vector3Test { [Test]
public void Vector3EqualityTest() { //Custom error 10e-6f
var actual = new Vector3(10e-8f, 10e-8f, 10e-8f);
var expected = new Vector3(0f, 0f, 0f);
var comparer = new Vector3EqualityComparer(10e-6f);
Assert.That(actual, Is.EqualTo(expected).Using(comparer));
//Default error 0.0001f
actual = new Vector3(0.01f, 0.01f, 0f);
expected = new Vector3(0.01f, 0.01f, 0f);
Assert.That(actual, Is.EqualTo(expected).Using(Vector3EqualityComparer.Instance)); } }