Skip to content

Commit 24386f0

Browse files
Update PathTests.cs
1 parent dfd3237 commit 24386f0

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4+
using System.Numerics;
5+
46
namespace SixLabors.ImageSharp.Drawing.Tests.Shapes;
57

68
/// <summary>
@@ -34,4 +36,53 @@ public void SimplePath()
3436
Assert.Equal(new PointF(10, 10), points[2]);
3537
Assert.Equal(new PointF(0, 10), points[3]);
3638
}
39+
40+
[Fact]
41+
public void EmptyPath_SingletonsExposeExpectedPathTypes()
42+
{
43+
Assert.Same(EmptyPath.OpenPath, Path.Empty);
44+
Assert.Equal(PathTypes.Open, EmptyPath.OpenPath.PathType);
45+
Assert.Equal(PathTypes.Closed, EmptyPath.ClosedPath.PathType);
46+
}
47+
48+
[Fact]
49+
public void EmptyPath_OperationsPreserveSingletons()
50+
{
51+
Matrix4x4 transform = Matrix4x4.CreateTranslation(12, 34, 0);
52+
53+
Assert.Same(EmptyPath.ClosedPath, EmptyPath.OpenPath.AsClosedPath());
54+
Assert.Same(EmptyPath.ClosedPath, EmptyPath.ClosedPath.AsClosedPath());
55+
Assert.Same(EmptyPath.OpenPath, EmptyPath.OpenPath.Transform(transform));
56+
Assert.Same(EmptyPath.ClosedPath, EmptyPath.ClosedPath.Transform(transform));
57+
}
58+
59+
[Fact]
60+
public void EmptyPath_ExposesNoPathData()
61+
{
62+
Assert.Equal(RectangleF.Empty, EmptyPath.OpenPath.Bounds);
63+
Assert.Equal(RectangleF.Empty, EmptyPath.ClosedPath.Bounds);
64+
Assert.Empty(EmptyPath.OpenPath.Flatten());
65+
Assert.Empty(EmptyPath.ClosedPath.Flatten());
66+
}
67+
68+
[Fact]
69+
public void EmptyPath_ToLinearGeometry_ReturnsEmptyGeometry()
70+
{
71+
LinearGeometry identity = EmptyPath.OpenPath.ToLinearGeometry(Vector2.One);
72+
LinearGeometry scaled = EmptyPath.ClosedPath.ToLinearGeometry(new Vector2(2F, 3F));
73+
74+
Assert.Same(identity, scaled);
75+
Assert.Equal(RectangleF.Empty, identity.Info.Bounds);
76+
Assert.Equal(0, identity.Info.ContourCount);
77+
Assert.Equal(0, identity.Info.PointCount);
78+
Assert.Equal(0, identity.Info.SegmentCount);
79+
Assert.Equal(0, identity.Info.NonHorizontalSegmentCountPixelBoundary);
80+
Assert.Equal(0, identity.Info.NonHorizontalSegmentCountPixelCenter);
81+
Assert.Empty(identity.Contours);
82+
Assert.Empty(identity.Points);
83+
84+
SegmentEnumerator segments = identity.GetSegments();
85+
86+
Assert.False(segments.MoveNext());
87+
}
3788
}

0 commit comments

Comments
 (0)