You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
865 B
30 lines
865 B
using System.Collections.Generic;
|
|
|
|
namespace UnityEngine.TestTools.Utils
|
|
{
|
|
public class FloatEqualityComparer : IEqualityComparer<float>
|
|
{
|
|
private const float k_DefaultError = 0.0001f;
|
|
private readonly float AllowedError;
|
|
|
|
private static readonly FloatEqualityComparer m_Instance = new FloatEqualityComparer();
|
|
public static FloatEqualityComparer Instance { get { return m_Instance; } }
|
|
|
|
private FloatEqualityComparer() : this(k_DefaultError) {}
|
|
|
|
public FloatEqualityComparer(float allowedError)
|
|
{
|
|
this.AllowedError = allowedError;
|
|
}
|
|
|
|
public bool Equals(float expected, float actual)
|
|
{
|
|
return Utils.AreFloatsEqual(expected, actual, AllowedError);
|
|
}
|
|
|
|
public int GetHashCode(float value)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
}
|