blob: 23640f6eb4c7d3d362f8989575dd2cad10c7f500 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
using System.Collections.Generic;
namespace UnityEngine.TestTools.Utils
{
public class Vector4EqualityComparer : IEqualityComparer<Vector4>
{
private const float k_DefaultError = 0.0001f;
private readonly float AllowedError;
private static readonly Vector4EqualityComparer m_Instance = new Vector4EqualityComparer();
public static Vector4EqualityComparer Instance { get { return m_Instance; } }
private Vector4EqualityComparer() : this(k_DefaultError) {}
public Vector4EqualityComparer(float allowedError)
{
this.AllowedError = allowedError;
}
public bool Equals(Vector4 expected, Vector4 actual)
{
return Utils.AreFloatsEqual(expected.x, actual.x, AllowedError) &&
Utils.AreFloatsEqual(expected.y, actual.y, AllowedError) &&
Utils.AreFloatsEqual(expected.z, actual.z, AllowedError) &&
Utils.AreFloatsEqual(expected.w, actual.w, AllowedError);
}
public int GetHashCode(Vector4 vec4)
{
return 0;
}
}
}
|