SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
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.

33 lines
966 B

4 years ago
  1. using System.Collections.Generic;
  2. namespace UnityEngine.TestTools.Utils
  3. {
  4. public class Vector2EqualityComparer : IEqualityComparer<Vector2>
  5. {
  6. private const float k_DefaultError = 0.0001f;
  7. private readonly float AllowedError;
  8. private static readonly Vector2EqualityComparer m_Instance = new Vector2EqualityComparer();
  9. public static Vector2EqualityComparer Instance { get { return m_Instance; } }
  10. private Vector2EqualityComparer() : this(k_DefaultError)
  11. {
  12. }
  13. public Vector2EqualityComparer(float error)
  14. {
  15. this.AllowedError = error;
  16. }
  17. public bool Equals(Vector2 expected, Vector2 actual)
  18. {
  19. return Utils.AreFloatsEqual(expected.x, actual.x, AllowedError) &&
  20. Utils.AreFloatsEqual(expected.y, actual.y, AllowedError);
  21. }
  22. public int GetHashCode(Vector2 vec2)
  23. {
  24. return 0;
  25. }
  26. }
  27. }