Skip to content

Commit d84cd09

Browse files
committed
Fix a test
This wasn't failing locally in either debug or release mode.
1 parent 932bf99 commit d84cd09

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

ProjNet.Tests/CoordinateTransformTests.cs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void TestTransformListOfCoordinates()
2929

3030
var trans = ctFact.CreateFromCoordinateSystems(utm35ETRS, utm33);
3131

32-
var points = new XY[]
32+
XY[] points =
3333
{
3434
new XY(290586.087, 6714000), new XY(290586.392, 6713996.224),
3535
new XY(290590.133, 6713973.772), new XY(290594.111, 6713957.416),
@@ -39,7 +39,17 @@ public void TestTransformListOfCoordinates()
3939
var tpoints = (XY[])points.Clone();
4040
trans.MathTransform.Transform(tpoints);
4141
for (int i = 0; i < points.Length; i++)
42-
Assert.That((tpoints[i].X, tpoints[i].Y), Is.EqualTo(trans.MathTransform.Transform(points[i].X, points[i].Y)));
42+
{
43+
double expectedX = points[i].X;
44+
double expectedY = points[i].Y;
45+
trans.MathTransform.Transform(ref expectedX, ref expectedY);
46+
47+
double actualX = tpoints[i].X;
48+
double actualY = tpoints[i].Y;
49+
50+
Assert.That(actualX, Is.EqualTo(expectedX).Within(1E-8));
51+
Assert.That(actualY, Is.EqualTo(expectedY).Within(1E-8));
52+
}
4353
}
4454

4555
[Test]
@@ -55,29 +65,26 @@ public void TestTransformListOfDoubleArray()
5565

5666
var trans = ctFact.CreateFromCoordinateSystems(utm35ETRS, utm33);
5767

58-
var points = new List<double[]>
68+
double[][] points =
5969
{
6070
new[] {290586.087, 6714000 }, new[] {90586.392, 6713996.224},
6171
new[] {290590.133, 6713973.772}, new[] {290594.111, 6713957.416},
6272
new[] {290596.615, 6713943.567}, new[] {290596.701, 6713939.485}
6373
};
6474

6575
double[][] tpoints = trans.MathTransform.TransformList(points).ToArray();
66-
for (int i = 0; i < points.Count; i++)
67-
Assert.IsTrue(Equal(tpoints[i], trans.MathTransform.Transform(points[i])));
68-
}
76+
for (int i = 0; i < points.Length; i++)
77+
{
78+
double expectedX = points[i][0];
79+
double expectedY = points[i][1];
80+
trans.MathTransform.Transform(ref expectedX, ref expectedY);
6981

70-
private static bool Equal(IList<double> a1, IList<double> a2)
71-
{
72-
if (a2.Count != a1.Count)
73-
return false;
82+
double actualX = tpoints[i][0];
83+
double actualY = tpoints[i][1];
7484

75-
for (int i = 0; i < a1.Count; i++)
76-
{
77-
if (!a1[i].Equals(a2[i]))
78-
return false;
85+
Assert.That(actualX, Is.EqualTo(expectedX).Within(1E-8));
86+
Assert.That(actualY, Is.EqualTo(expectedY).Within(1E-8));
7987
}
80-
return true;
8188
}
8289

8390
[Test]

0 commit comments

Comments
 (0)