Skip to content

Commit 8774c97

Browse files
committed
added test for 0 valued radii
1 parent e30c216 commit 8774c97

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

src/ImageSharp.Drawing/Shapes/EllipticalArcLineSegment.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public sealed class EllipticalArcLineSegment : ILineSegment
3737
/// <param name="transformation">The Tranformation matrix, that should be used on the arc.</param>
3838
public EllipticalArcLineSegment(float x, float y, float radiusX, float radiusY, float rotation, float startAngle, float sweepAngle, Matrix3x2 transformation)
3939
{
40-
Guard.MustBeGreaterThan(radiusX, 0, nameof(radiusX));
41-
Guard.MustBeGreaterThan(radiusY, 0, nameof(radiusY));
40+
Guard.MustBeGreaterThanOrEqualTo(radiusX, 0, nameof(radiusX));
41+
Guard.MustBeGreaterThanOrEqualTo(radiusY, 0, nameof(radiusY));
4242
this.x = x;
4343
this.y = y;
4444
this.radiusX = radiusX;

tests/ImageSharp.Drawing.Tests/Shapes/EllipticalArcLineSegmentTest.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,28 @@ public void ContainsStartandEnd()
1919
Assert.Equal(20, segment.EndPoint.X, 5);
2020
Assert.Equal(10, segment.EndPoint.Y, 5);
2121
}
22+
23+
[Fact]
24+
public void checkZeroRadii()
25+
{
26+
IReadOnlyCollection<PointF> xRadiusZero = new EllipticalArcLineSegment(20, 10, 0, 20, 0, 0, 360, Matrix3x2.Identity).Flatten().ToArray();
27+
IReadOnlyCollection<PointF> yRadiusZero = new EllipticalArcLineSegment(20, 10, 30, 0, 0, 0, 360, Matrix3x2.Identity).Flatten().ToArray();
28+
IReadOnlyCollection<PointF> bothRadiiZero = new EllipticalArcLineSegment(20, 10, 0, 0, 0, 0, 360, Matrix3x2.Identity).Flatten().ToArray();
29+
foreach (PointF point in xRadiusZero)
30+
{
31+
Assert.Equal(20, point.X);
32+
}
33+
34+
foreach (PointF point in yRadiusZero)
35+
{
36+
Assert.Equal(10, point.Y);
37+
}
38+
39+
foreach (PointF point in bothRadiiZero)
40+
{
41+
Assert.Equal(20, point.X);
42+
Assert.Equal(10, point.Y);
43+
}
44+
}
2245
}
2346
}

0 commit comments

Comments
 (0)