diff --git a/tests/ImageSharp.Tests/TestUtilities/FloatRoundingComparer.cs b/tests/ImageSharp.Tests/TestUtilities/FloatRoundingComparer.cs
index 8bf5abbe1..dd3ef3a4f 100644
--- a/tests/ImageSharp.Tests/TestUtilities/FloatRoundingComparer.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/FloatRoundingComparer.cs
@@ -1,12 +1,13 @@
-namespace ImageSharp.Tests.TestUtilities
+namespace ImageSharp.Tests
{
using System;
using System.Collections.Generic;
+ using System.Numerics;
///
/// Allows the comparison of single-precision floating point values by precision.
///
- public struct FloatRoundingComparer : IEqualityComparer
+ public struct FloatRoundingComparer : IEqualityComparer, IEqualityComparer
{
///
/// Initializes a new instance of the struct.
@@ -14,6 +15,7 @@
/// The number of decimal places (valid values: 0-7)
public FloatRoundingComparer(int precision)
{
+ Guard.MustBeBetweenOrEqualTo(precision, 0, 7, nameof(precision));
this.Precision = precision;
}
@@ -31,6 +33,12 @@
return Comparer.Default.Compare(xp, yp) == 0;
}
+ ///
+ public bool Equals(Vector4 x, Vector4 y)
+ {
+ return Equals(x.X, y.X) && Equals(x.Y, y.Y) && Equals(x.Z, y.Z) && Equals(x.W, y.W);
+ }
+
///
public int GetHashCode(float obj)
{
@@ -41,5 +49,16 @@
return hashCode;
}
}
+
+ ///
+ public int GetHashCode(Vector4 obj)
+ {
+ unchecked
+ {
+ int hashCode = obj.GetHashCode();
+ hashCode = (hashCode * 397) ^ this.Precision.GetHashCode();
+ return hashCode;
+ }
+ }
}
}
\ No newline at end of file