Skip to content

Commit 4e9eb8f

Browse files
committed
adapt tests
1 parent de5b04f commit 4e9eb8f

9 files changed

Lines changed: 13 additions & 274 deletions

File tree

tests/ImageSharp.Drawing.Tests/Drawing/FillPathGradientBrushTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,11 @@ public void FillComplex<TPixel>(TestImageProvider<TPixel> provider)
196196
{
197197
var star = new Star(50, 50, 5, 20, 45);
198198
PointF[] points = star.Points.ToArray();
199-
Color[] colors = { Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.Purple,
200-
Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.Purple };
199+
Color[] colors =
200+
{
201+
Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.Purple,
202+
Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.Purple
203+
};
201204

202205
var brush = new PathGradientBrush(points, colors, Color.White);
203206

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

Lines changed: 0 additions & 47 deletions
This file was deleted.

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

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

44
using System;
5-
using System.Linq;
65
using Xunit;
76

87
namespace SixLabors.ImageSharp.Drawing.Tests
@@ -85,26 +84,6 @@ private static InternalPath Create(PointF location, SizeF size, bool closed = tr
8584
},
8685
};
8786

88-
[Theory]
89-
[MemberData(nameof(PointInPolygonTheoryData))]
90-
public void PointInPolygon(TestPoint location, TestSize size, TestPoint point, bool isInside)
91-
{
92-
InternalPath shape = Create(location, size);
93-
Assert.Equal(isInside, shape.PointInPolygon(point));
94-
}
95-
96-
[Fact]
97-
public void PointInPolygon_OpenPath()
98-
{
99-
var seg1 = new LinearLineSegment(new PointF(0, 0), new PointF(0, 10), new PointF(10, 10), new PointF(10, 0));
100-
101-
var p = new InternalPath(seg1, false);
102-
Assert.False(p.PointInPolygon(new PointF(5, 5)));
103-
104-
var p2 = new InternalPath(seg1, true);
105-
Assert.True(p2.PointInPolygon(new PointF(5, 5f)));
106-
}
107-
10887
private const float HalfPi = (float)(Math.PI / 2);
10988
private const float Pi = (float)Math.PI;
11089

@@ -123,114 +102,5 @@ public void PointOnPath(float distance, float expectedX, float expectedY, float
123102
Assert.Equal(expectedY, point.Point.Y, 4);
124103
Assert.Equal(expectedAngle, point.Angle, 4);
125104
}
126-
127-
[Fact]
128-
public void Intersections_buffer()
129-
{
130-
InternalPath shape = Create(new PointF(0, 0), new Size(10, 10));
131-
var intersections = new PointF[shape.PointCount];
132-
var orientations = new PointOrientation[shape.PointCount];
133-
int hits = shape.FindIntersections(new PointF(5, -10), new PointF(5, 20), intersections, orientations);
134-
135-
Assert.Equal(2, hits);
136-
Assert.Equal(new PointF(5, 0), intersections[0]);
137-
Assert.Equal(new PointF(5, 10), intersections[1]);
138-
}
139-
140-
[Fact]
141-
public void Intersections_enumerabe()
142-
{
143-
InternalPath shape = Create(new PointF(0, 0), new Size(10, 10));
144-
PointF[] buffer = shape.FindIntersections(new PointF(5, -10), new PointF(5, 20)).ToArray();
145-
146-
Assert.Equal(2, buffer.Length);
147-
Assert.Equal(new PointF(5, 0), buffer[0]);
148-
Assert.Equal(new PointF(5, 10), buffer[1]);
149-
}
150-
151-
[Fact]
152-
public void Intersections_enumerabe_openpath()
153-
{
154-
InternalPath shape = Create(new PointF(0, 0), new Size(10, 10), false);
155-
PointF[] buffer = shape.FindIntersections(new PointF(5, -10), new PointF(5, 20)).ToArray();
156-
157-
Assert.Equal(2, buffer.Length);
158-
Assert.Equal(new PointF(5, 0), buffer[0]);
159-
Assert.Equal(new PointF(5, 10), buffer[1]);
160-
}
161-
162-
[Fact]
163-
public void Intersections_Diagonal()
164-
{
165-
var shape = new InternalPath(new LinearLineSegment(new PointF(0, 0), new PointF(10, 10)), false);
166-
167-
PointF[] buffer = shape.FindIntersections(new PointF(0, 10), new PointF(10, 0)).ToArray();
168-
169-
Assert.Single(buffer);
170-
Assert.Equal(new PointF(5, 5), buffer[0]);
171-
}
172-
173-
[Fact]
174-
public void Intersections_Diagonal_NoHit()
175-
{
176-
var shape = new InternalPath(new LinearLineSegment(new PointF(0, 0), new PointF(4, 4)), false);
177-
178-
PointF[] buffer = shape.FindIntersections(new PointF(0, 10), new PointF(10, 0)).ToArray();
179-
180-
Assert.Empty(buffer);
181-
}
182-
183-
[Fact]
184-
public void Intersections_Diagonal_and_straight_NoHit()
185-
{
186-
var shape = new InternalPath(new LinearLineSegment(new PointF(0, 0), new PointF(4, 4)), false);
187-
188-
PointF[] buffer = shape.FindIntersections(new PointF(3, 10), new PointF(3, 3.5f)).ToArray();
189-
190-
Assert.Empty(buffer);
191-
}
192-
193-
[Fact]
194-
public void Intersections_IntersectionRule_OddEven()
195-
{
196-
var shape = new InternalPath(
197-
new LinearLineSegment(
198-
new PointF(1, 3),
199-
new PointF(1, 2),
200-
new PointF(5, 2),
201-
new PointF(5, 5),
202-
new PointF(2, 5),
203-
new PointF(2, 1),
204-
new PointF(3, 1),
205-
new PointF(3, 4),
206-
new PointF(4, 4),
207-
new PointF(3, 4)), true);
208-
209-
PointF[] buffer = shape.FindIntersections(new PointF(0, 2.5f), new PointF(6, 2.5f), IntersectionRule.OddEven).ToArray();
210-
211-
Assert.Equal(4, buffer.Length);
212-
}
213-
214-
[Fact]
215-
public void Intersections_IntersectionRule_Nonezero()
216-
{
217-
var shape = new InternalPath(
218-
new LinearLineSegment(
219-
new PointF(1, 3),
220-
new PointF(1, 2),
221-
new PointF(5, 2),
222-
new PointF(5, 5),
223-
new PointF(2, 5),
224-
new PointF(2, 1),
225-
new PointF(3, 1),
226-
new PointF(3, 4),
227-
new PointF(4, 4),
228-
new PointF(3, 4)),
229-
true);
230-
231-
PointF[] buffer = shape.FindIntersections(new PointF(0, 2.5f), new PointF(6, 2.5f), IntersectionRule.Nonzero).ToArray();
232-
233-
Assert.Equal(2, buffer.Length);
234-
}
235105
}
236106
}

tests/ImageSharp.Drawing.Tests/Shapes/Issues/Issue_16.cs

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/ImageSharp.Drawing.Tests/Shapes/Issues/Issue_19.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@ namespace SixLabors.ImageSharp.Drawing.Tests
1414
/// </summary>
1515
public class Issue_19
1616
{
17-
[Fact]
18-
public void LoosingPartOfLineIfSelfIntersects()
19-
{
20-
var line1 = new PointF[] { new Vector2(117f, 199f), new Vector2(31f, 210f), new Vector2(35f, 191f), new Vector2(117f, 199f), new Vector2(2f, 9f) };
21-
var path = new Path(new LinearLineSegment(line1));
22-
23-
IPath outline = path.GenerateOutline(5f);
24-
25-
// all points must not be in the outline;
26-
foreach (PointF v in line1)
27-
{
28-
Assert.True(outline.Contains(v), $"Outline does not contain {v}");
29-
}
30-
}
31-
3217
[Fact]
3318
public void PAthLoosingSelfIntersectingPoint()
3419
{

tests/ImageSharp.Drawing.Tests/Shapes/Issues/Issue_ClippedPaths.cs

Lines changed: 0 additions & 29 deletions
This file was deleted.

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,8 @@ public class PolygonTests
3535
}, // corner is inside
3636
};
3737

38-
[Theory]
39-
[MemberData(nameof(PointInPolygonTheoryData))]
40-
public void PointInPolygon(TestPoint[] controlPoints, TestPoint point, bool isInside)
41-
{
42-
var shape = new Polygon(new LinearLineSegment(controlPoints.Select(x => (PointF)x).ToArray()));
43-
Assert.Equal(isInside, shape.Contains(point));
44-
}
45-
4638
public static TheoryData<TestPoint[], TestPoint, float> DistanceTheoryData =
47-
new TheoryData<TestPoint[], TestPoint, float>
39+
new ()
4840
{
4941
{
5042
new TestPoint[] { new PointF(10, 10), new PointF(10, 100), new PointF(100, 100), new PointF(100, 10) },

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,6 @@ public class RectangleTests
6969
},
7070
};
7171

72-
[Theory]
73-
[MemberData(nameof(PointInPolygonTheoryData))]
74-
public void PointInPolygon(TestPoint location, TestSize size, TestPoint point, bool isInside)
75-
{
76-
var shape = new RectangularPolygon(location, size);
77-
Assert.Equal(isInside, shape.Contains(point));
78-
}
79-
8072
[Fact]
8173
public void Left()
8274
{

tests/ImageSharp.Drawing.Tests/Utilities/IntersectTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ public class IntersectTests
1313
new ()
1414
{
1515
{ (0, 0), (2, 3), (1, 3), (1, 0), (1, 1.5f) },
16-
{ (3, 1), (3, 3), (3, 2), (4, 2), (3, 2)},
17-
{ (1, -3), (3, -1), (3, -4), (2, -2), (2, -2)},
18-
{ (0, 0), (2, 1), (2, 1.0001f), (5, 2), (2, 1)}, // Robust to inaccuracies
16+
{ (3, 1), (3, 3), (3, 2), (4, 2), (3, 2) },
17+
{ (1, -3), (3, -1), (3, -4), (2, -2), (2, -2) },
18+
{ (0, 0), (2, 1), (2, 1.0001f), (5, 2), (2, 1) }, // Robust to inaccuracies
1919
{ (0, 0), (2, 3), (1, 3), (1, 2), null },
20-
{ (-3, 3), (-1, 3), (-3, 2), (-1, 2), null},
21-
{ (-4, 3), (-4, 1), (-5, 3), (-5, 1), null},
22-
{ (0, 0), (4, 1), (4, 1), (8, 2), null}, // Collinear intersections are ignored
23-
{ (0, 0), (4, 1), (4, 1.0001f), (8, 2), null}, // Collinear intersections are ignored
20+
{ (-3, 3), (-1, 3), (-3, 2), (-1, 2), null },
21+
{ (-4, 3), (-4, 1), (-5, 3), (-5, 1), null },
22+
{ (0, 0), (4, 1), (4, 1), (8, 2), null }, // Collinear intersections are ignored
23+
{ (0, 0), (4, 1), (4, 1.0001f), (8, 2), null }, // Collinear intersections are ignored
2424
};
2525

2626
[Theory]

0 commit comments

Comments
 (0)