Browse Source

Made TolerantMath.Default a readonly property,

allow consuming one-dimensional input in ImageDataAttribute.
af/merge-core
Anton Firszov 7 years ago
parent
commit
3632999aa7
  1. 9
      src/ImageSharp/Common/Helpers/TolerantMath.cs
  2. 2
      tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs

9
src/ImageSharp/Common/Helpers/TolerantMath.cs

@ -16,6 +16,13 @@ namespace SixLabors.ImageSharp
private readonly double negEpsilon;
/// <summary>
/// A read-only default instance for <see cref="TolerantMath"/> using 1e-8 as epsilon.
/// It is a field so it can be passed as an 'in' parameter.
/// Does not necessarily fit all use cases!
/// </summary>
public static readonly TolerantMath Default = new TolerantMath(1e-8);
public TolerantMath(double epsilon)
{
DebugGuard.MustBeGreaterThan(epsilon, 0, nameof(epsilon));
@ -24,8 +31,6 @@ namespace SixLabors.ImageSharp
this.negEpsilon = -epsilon;
}
public static TolerantMath Default { get; } = new TolerantMath(1e-8);
/// <summary>
/// <paramref name="a"/> == 0
/// </summary>

2
tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs

@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests
addedRows = memberItems.Select(x => x as object[]);
if (addedRows.Any(x => x == null))
{
throw new ArgumentException($"Property {this.MemberName} on {this.MemberType ?? testMethod.DeclaringType} yielded an item that is not an object[]");
addedRows = memberItems.Select(x => new[] { x });
}
}
}

Loading…
Cancel
Save