Skip to content

Commit 0d1ad3d

Browse files
Update tests
1 parent 30df10a commit 0d1ad3d

29 files changed

Lines changed: 58 additions & 44 deletions

File tree

tests/ImageSharp.Drawing.Tests/Drawing/Paths/ClearRectangle.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ namespace SixLabors.ImageSharp.Drawing.Tests.Drawing.Paths
1212
public class ClearRectangle : BaseImageOperationsExtensionTest
1313
{
1414
private readonly Brush brush = Brushes.Solid(Color.HotPink);
15-
private RectangleF rectangle = new RectangleF(10, 10, 20, 20);
15+
private RectangleF rectangle = new(10, 10, 20, 20);
1616

17-
private RectangularPolygon RectanglePolygon => new RectangularPolygon(this.rectangle);
17+
private RectangularPolygon RectanglePolygon => new(this.rectangle);
1818

1919
[Fact]
2020
public void Brush()

tests/ImageSharp.Drawing.Tests/Shapes/PolygonClipper/ClipperTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void OverlappingTriangles()
7373
Assert.Equal(7, path.Count);
7474
foreach (Vector2 p in this.bigTriangle.Flatten().First().Points.ToArray())
7575
{
76-
Assert.Contains(p, path, new ApproximateFloatComparer(.0001F));
76+
Assert.Contains(p, path, new ApproximateFloatComparer(RectangularPolygonValueComparer.DefaultTolerance));
7777
}
7878
}
7979

@@ -108,9 +108,8 @@ public void OverlappingButNotCrossingReturnsOrigionalShapes()
108108

109109
Assert.Equal(2, shapes.Count());
110110

111-
const float epsilon = 0.0001F;
112-
Assert.Contains(shapes, x => RectangularPolygonValueComparer.Equals(this.bigSquare, x, epsilon));
113-
Assert.Contains(shapes, x => RectangularPolygonValueComparer.Equals(this.hole, x, epsilon));
111+
Assert.Contains(shapes, x => RectangularPolygonValueComparer.Equals(this.bigSquare, x));
112+
Assert.Contains(shapes, x => RectangularPolygonValueComparer.Equals(this.hole, x));
114113
}
115114

116115
[Fact]

tests/ImageSharp.Drawing.Tests/TestUtilities/RectangularPolygonValueComparer.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
5+
using SixLabors.ImageSharp.Drawing.Shapes.PolygonClipper;
56

67
namespace SixLabors.ImageSharp.Drawing.Tests.TestUtilities
78
{
@@ -10,13 +11,15 @@ namespace SixLabors.ImageSharp.Drawing.Tests.TestUtilities
1011
/// </summary>
1112
internal static class RectangularPolygonValueComparer
1213
{
13-
public static bool Equals(RectangularPolygon x, RectangularPolygon y, float epsilon = 0F)
14+
public const float DefaultTolerance = ClipperUtils.FloatingPointTolerance;
15+
16+
public static bool Equals(RectangularPolygon x, RectangularPolygon y, float epsilon = DefaultTolerance)
1417
=> Math.Abs(x.Left - y.Left) < epsilon
1518
&& Math.Abs(x.Top - y.Top) < epsilon
1619
&& Math.Abs(x.Right - y.Right) < epsilon
1720
&& Math.Abs(x.Bottom - y.Bottom) < epsilon;
1821

19-
public static bool Equals(RectangularPolygon x, object y, float epsilon = 0F)
22+
public static bool Equals(RectangularPolygon x, object y, float epsilon = DefaultTolerance)
2023
=> y is RectangularPolygon polygon && Equals(x, polygon, epsilon);
2124
}
2225
}
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)