GlobalGameJame/Library/PackageCache/com.unity.test-framework@1.1.9/UnityEngine.TestRunner/Utils/FloatEqualityComparer.cs
JonatanRek bea2dce063 Initial
test
2020-01-31 16:10:04 +01:00

31 lines
865 B
C#

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;
}
}
}