Skip to content

Commit 28bf98c

Browse files
authored
fix tests always passing (#33)
fix tests always passing Now it calls FactCheck.exitstatus() to get the right exit code for CI. Also wrapping the test code blocks to get logging of which tests fail. All failing tests are also fixed in this commit: `getCoordinates(coordseq)` returns a vector of points, whereas `getCoordinates(coordseq,i)` should return a single point factcheck_equals -> at-fact look at just the first 2 coordinates since LibGEOS returns points with coordinate dimension 3, but NaN in the third dimension. This is consistent with known behavior: https://github.com/JuliaGeo/LibGEOS.jl/blob/929a4fa24b9e3ba70090fa752347 1a8f2788ff0f/test/test_geos_functions.jl#L331-L332 remove stray parentheses fix wrong test output
1 parent 929a4fa commit 28bf98c

File tree

4 files changed

+975
-987
lines changed

4 files changed

+975
-987
lines changed

test/runtests.jl

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
11
import GeoInterface
22
using FactCheck, LibGEOS
33

4-
function factcheck_equals(obj1::Vector{Vector{Float64}},
5-
obj2::Vector{Vector{Float64}}; tol=1e-5)
6-
for (i,item) in enumerate(obj2)
7-
@fact obj1[i] --> roughly(item, tol)
8-
end
9-
end
10-
11-
function factcheck_equals(obj1::Vector{Vector{Vector{Float64}}},
12-
obj2::Vector{Vector{Vector{Float64}}}; tol=1e-5)
13-
for (i,item) in enumerate(obj2)
14-
factcheck_equals(obj1[i], item, tol=tol)
15-
end
16-
end
17-
18-
function factcheck_equals(obj1::Vector{Vector{Vector{Vector{Float64}}}},
19-
obj2::Vector{Vector{Vector{Vector{Float64}}}}; tol=1e-5)
20-
for (i,item) in enumerate(obj2)
21-
factcheck_equals(obj1[i], item, tol=tol)
22-
end
23-
end
24-
254
include("test_geos_functions.jl")
265
include("test_geos_operations.jl")
276
include("test_geo_interface.jl")
7+
8+
FactCheck.exitstatus()

test/test_geo_interface.jl

Lines changed: 68 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,83 @@
1+
facts("Geo interface") do
2+
pt = LibGEOS.Point(1.0,2.0)
3+
@fact GeoInterface.coordinates(pt) --> roughly([1,2], 1e-5)
4+
@fact GeoInterface.geotype(pt) --> :Point
15

2-
pt = LibGEOS.Point(1.0,2.0)
3-
@fact GeoInterface.coordinates(pt) --> roughly([1,2], 1e-5)
4-
@fact GeoInterface.geotype(pt) --> :Point
6+
pt = LibGEOS.Point(1, 2)
7+
@fact GeoInterface.coordinates(pt) --> roughly([1,2], 1e-5)
8+
@fact GeoInterface.geotype(pt) --> :Point
59

6-
pt = LibGEOS.Point(1, 2)
7-
@fact GeoInterface.coordinates(pt) --> roughly([1,2], 1e-5)
8-
@fact GeoInterface.geotype(pt) --> :Point
910

11+
pt = LibGEOS.Point(LibGEOS.geomFromWKT("POINT EMPTY"))
12+
@fact GeoInterface.coordinates(pt) --> roughly(Float64[], 1e-5)
13+
@fact GeoInterface.geotype(pt) --> :Point
1014

11-
pt = LibGEOS.Point(LibGEOS.geomFromWKT("POINT EMPTY"))
12-
@fact GeoInterface.coordinates(pt) --> roughly(Float64[], 1e-5)
13-
@fact GeoInterface.geotype(pt) --> :Point
15+
mpt = LibGEOS.MultiPoint(LibGEOS.geomFromWKT("MULTIPOINT(0 0, 10 0, 10 10, 11 10)"))
16+
@fact GeoInterface.coordinates(mpt) --> Vector{Float64}[[0,0],[10,0],[10,10],[11,10]]
17+
@fact GeoInterface.geotype(mpt) --> :MultiPoint
1418

15-
mpt = LibGEOS.MultiPoint(LibGEOS.geomFromWKT("MULTIPOINT(0 0, 10 0, 10 10, 11 10)"))
16-
factcheck_equals(GeoInterface.coordinates(mpt), Vector{Float64}[[0,0],[10,0],[10,10],[11,10]])
17-
@fact GeoInterface.geotype(mpt) --> :MultiPoint
19+
coords = Vector{Float64}[[8,1],[9,1],[9,2],[8,2]]
20+
ls = LibGEOS.LineString(coords)
21+
@fact GeoInterface.coordinates(ls) --> coords
22+
@fact GeoInterface.geotype(ls) --> :LineString
1823

19-
coords = Vector{Float64}[[8,1],[9,1],[9,2],[8,2]]
20-
ls = LibGEOS.LineString(coords)
21-
factcheck_equals(GeoInterface.coordinates(ls), coords)
22-
@fact GeoInterface.geotype(ls) --> :LineString
24+
ls = LibGEOS.LineString(LibGEOS.geomFromWKT("LINESTRING EMPTY"))
25+
@fact GeoInterface.coordinates(ls) --> []
26+
@fact GeoInterface.geotype(ls) --> :LineString
2327

24-
ls = LibGEOS.LineString(LibGEOS.geomFromWKT("LINESTRING EMPTY"))
25-
factcheck_equals(GeoInterface.coordinates(ls), Vector{Float64}[[]])
26-
@fact GeoInterface.geotype(ls) --> :LineString
28+
mls = LibGEOS.MultiLineString(LibGEOS.geomFromWKT("MULTILINESTRING ((5 0, 10 0), (0 0, 5 0))"))
29+
@fact GeoInterface.coordinates(mls) --> [[[5,0],[10,0]],[[0,0],[5,0]]]
30+
@fact GeoInterface.geotype(mls) --> :MultiLineString
2731

28-
mls = LibGEOS.MultiLineString(LibGEOS.geomFromWKT("MULTILINESTRING ((5 0, 10 0), (0 0, 5 0))"))
29-
factcheck_equals(GeoInterface.coordinates(mls), Vector{Vector{Float64}}[Vector{Float64}[[5,0],[0,0],[5,0]]])
30-
@fact GeoInterface.geotype(mls) --> :MultiLineString
32+
coords = Vector{Float64}[[8,1],[9,1],[9,2],[8,2],[8,1]]
33+
lr = LibGEOS.LinearRing(coords)
34+
@fact GeoInterface.coordinates(lr) --> coords
35+
@fact GeoInterface.geotype(lr) --> :LineString
3136

32-
coords = Vector{Float64}[[8,1],[9,1],[9,2],[8,2],[8,1]]
33-
lr = LibGEOS.LinearRing(coords)
34-
factcheck_equals(GeoInterface.coordinates(lr), coords)
35-
@fact GeoInterface.geotype(lr) --> :LineString
37+
coords = Vector{Vector{Float64}}[Vector{Float64}[[0,0],[10,0],[10,10],[0,10],[0,0]],
38+
Vector{Float64}[[1,8],[2,8],[2,9],[1,9],[1,8]],
39+
Vector{Float64}[[8,1],[9,1],[9,2],[8,2],[8,1]]]
40+
polygon = LibGEOS.Polygon(coords)
41+
@fact GeoInterface.coordinates(polygon) --> coords
42+
@fact GeoInterface.geotype(polygon) --> :Polygon
3643

37-
coords = Vector{Vector{Float64}}[Vector{Float64}[[0,0],[10,0],[10,10],[0,10],[0,0]],
38-
Vector{Float64}[[1,8],[2,8],[2,9],[1,9],[1,8]],
39-
Vector{Float64}[[8,1],[9,1],[9,2],[8,2],[8,1]]]
40-
polygon = LibGEOS.Polygon(coords)
41-
factcheck_equals(GeoInterface.coordinates(polygon), coords)
42-
@fact GeoInterface.geotype(polygon) --> :Polygon
44+
polygon = LibGEOS.Polygon(LibGEOS.geomFromWKT("POLYGON EMPTY"))
45+
@fact GeoInterface.coordinates(polygon) --> [[]]
46+
@fact GeoInterface.geotype(polygon) --> :Polygon
4347

44-
polygon = LibGEOS.Polygon(LibGEOS.geomFromWKT("POLYGON EMPTY"))
45-
factcheck_equals(GeoInterface.coordinates(polygon), Vector{Vector{Float64}}[[]])
46-
@fact GeoInterface.geotype(polygon) --> :Polygon
48+
multipolygon = LibGEOS.MultiPolygon(LibGEOS.geomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))"))
49+
@fact GeoInterface.coordinates(multipolygon) --> Vector{Vector{Vector{Float64}}}[Vector{Vector{Float64}}[Vector{Float64}[[0,0],[0,10],[10,10],[10,0],[0,0]]]]
50+
@fact GeoInterface.geotype(multipolygon) --> :MultiPolygon
4751

48-
multipolygon = LibGEOS.MultiPolygon(LibGEOS.geomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))"))
49-
factcheck_equals(GeoInterface.coordinates(multipolygon), Vector{Vector{Vector{Float64}}}[Vector{Vector{Float64}}[Vector{Float64}[[0,0],[0,10],[10,10],[10,0],[0,0]]]])
50-
@fact GeoInterface.geotype(multipolygon) --> :MultiPolygon
52+
geomcollection = LibGEOS.GeometryCollection(LibGEOS.geomFromWKT("GEOMETRYCOLLECTION (POLYGON ((8 2, 10 10, 8.5 1, 8 2)), POLYGON ((7 8, 10 10, 8 2, 7 8)), POLYGON ((3 8, 10 10, 7 8, 3 8)), POLYGON ((2 2, 8 2, 8.5 1, 2 2)), POLYGON ((2 2, 7 8, 8 2, 2 2)), POLYGON ((2 2, 3 8, 7 8, 2 2)), POLYGON ((0.5 9, 10 10, 3 8, 0.5 9)), POLYGON ((0.5 9, 3 8, 2 2, 0.5 9)), POLYGON ((0 0, 2 2, 8.5 1, 0 0)), POLYGON ((0 0, 0.5 9, 2 2, 0 0)))"))
53+
collection = GeoInterface.geometries(geomcollection)
54+
coords = Vector{Vector{Vector{Float64}}}[Vector{Vector{Float64}}[Vector{Float64}[[8.0,2.0],[10.0,10.0],[8.5,1.0],[8.0,2.0]]],
55+
Vector{Vector{Float64}}[Vector{Float64}[[7.0,8.0],[10.0,10.0],[8.0,2.0],[7.0,8.0]]],
56+
Vector{Vector{Float64}}[Vector{Float64}[[3.0,8.0],[10.0,10.0],[7.0,8.0],[3.0,8.0]]],
57+
Vector{Vector{Float64}}[Vector{Float64}[[2.0,2.0],[ 8.0, 2.0],[8.5,1.0],[2.0,2.0]]],
58+
Vector{Vector{Float64}}[Vector{Float64}[[2.0,2.0],[ 7.0, 8.0],[8.0,2.0],[2.0,2.0]]],
59+
Vector{Vector{Float64}}[Vector{Float64}[[2.0,2.0],[ 3.0, 8.0],[7.0,8.0],[2.0,2.0]]],
60+
Vector{Vector{Float64}}[Vector{Float64}[[0.5,9.0],[10.0,10.0],[3.0,8.0],[0.5,9.0]]],
61+
Vector{Vector{Float64}}[Vector{Float64}[[0.5,9.0],[ 3.0, 8.0],[2.0,2.0],[0.5,9.0]]],
62+
Vector{Vector{Float64}}[Vector{Float64}[[0.0,0.0],[ 2.0, 2.0],[8.5,1.0],[0.0,0.0]]],
63+
Vector{Vector{Float64}}[Vector{Float64}[[0.0,0.0],[ 0.5, 9.0],[2.0,2.0],[0.0,0.0]]]]
64+
@fact map(GeoInterface.coordinates,collection) --> coords
65+
@fact GeoInterface.geotype(geomcollection) --> :GeometryCollection
5166

52-
geomcollection = LibGEOS.GeometryCollection(LibGEOS.geomFromWKT("GEOMETRYCOLLECTION (POLYGON ((8 2, 10 10, 8.5 1, 8 2)), POLYGON ((7 8, 10 10, 8 2, 7 8)), POLYGON ((3 8, 10 10, 7 8, 3 8)), POLYGON ((2 2, 8 2, 8.5 1, 2 2)), POLYGON ((2 2, 7 8, 8 2, 2 2)), POLYGON ((2 2, 3 8, 7 8, 2 2)), POLYGON ((0.5 9, 10 10, 3 8, 0.5 9)), POLYGON ((0.5 9, 3 8, 2 2, 0.5 9)), POLYGON ((0 0, 2 2, 8.5 1, 0 0)), POLYGON ((0 0, 0.5 9, 2 2, 0 0)))"))
53-
collection = GeoInterface.geometries(geomcollection)
54-
coords = Vector{Vector{Vector{Float64}}}[Vector{Vector{Float64}}[Vector{Float64}[[8.0,2.0],[10.0,10.0],[8.5,1.0],[8.0,2.0]]],
55-
Vector{Vector{Float64}}[Vector{Float64}[[7.0,8.0],[10.0,10.0],[8.0,2.0],[7.0,8.0]]],
56-
Vector{Vector{Float64}}[Vector{Float64}[[3.0,8.0],[10.0,10.0],[7.0,8.0],[3.0,8.0]]],
57-
Vector{Vector{Float64}}[Vector{Float64}[[2.0,2.0],[ 8.0, 2.0],[8.5,1.0],[2.0,2.0]]],
58-
Vector{Vector{Float64}}[Vector{Float64}[[2.0,2.0],[ 7.0, 8.0],[8.0,2.0],[2.0,2.0]]],
59-
Vector{Vector{Float64}}[Vector{Float64}[[2.0,2.0],[ 3.0, 8.0],[7.0,8.0],[2.0,2.0]]],
60-
Vector{Vector{Float64}}[Vector{Float64}[[0.5,9.0],[10.0,10.0],[3.0,8.0],[0.5,9.0]]],
61-
Vector{Vector{Float64}}[Vector{Float64}[[0.5,9.0],[ 3.0, 8.0],[2.0,2.0],[0.5,9.0]]],
62-
Vector{Vector{Float64}}[Vector{Float64}[[0.0,0.0],[ 2.0, 2.0],[8.5,1.0],[0.0,0.0]]],
63-
Vector{Vector{Float64}}[Vector{Float64}[[0.0,0.0],[ 0.5, 9.0],[2.0,2.0],[0.0,0.0]]]]
64-
factcheck_equals(map(GeoInterface.coordinates,collection),coords)
65-
@fact GeoInterface.geotype(geomcollection) --> :GeometryCollection
67+
geomcollection = LibGEOS.GeometryCollection(LibGEOS.geomFromWKT("GEOMETRYCOLLECTION(MULTIPOINT(0 0, 0 0, 1 1),LINESTRING(1 1, 2 2, 2 2, 0 0),POLYGON((5 5, 0 0, 0 2, 2 2, 5 5)))"))
68+
collection = GeoInterface.geometries(geomcollection)
69+
coords = Vector[Vector{Float64}[[0.0,0.0],[0.0,0.0],[1.0,1.0]],
70+
Vector{Float64}[[1.0,1.0],[2.0,2.0],[2.0,2.0],[0.0,0.0]],
71+
Vector{Vector{Float64}}[Vector{Float64}[[5.0,5.0],[0.0,0.0],[0.0,2.0],[2.0,2.0],[5.0,5.0]]]]
72+
geotypes = [:MultiPoint,:LineString,:Polygon]
73+
for (i,item) in enumerate(collection)
74+
@fact GeoInterface.coordinates(item) --> coords[i]
75+
@fact GeoInterface.geotype(item) --> geotypes[i]
76+
end
77+
@fact GeoInterface.geotype(geomcollection) --> :GeometryCollection
6678

67-
geomcollection = LibGEOS.GeometryCollection(LibGEOS.geomFromWKT("GEOMETRYCOLLECTION(MULTIPOINT(0 0, 0 0, 1 1),LINESTRING(1 1, 2 2, 2 2, 0 0),POLYGON((5 5, 0 0, 0 2, 2 2, 5 5)))"))
68-
collection = GeoInterface.geometries(geomcollection)
69-
coords = Vector[Vector{Float64}[[0.0,0.0],[0.0,0.0],[1.0,1.0]],
70-
Vector{Float64}[[1.0,1.0],[2.0,2.0],[2.0,2.0],[0.0,0.0]],
71-
Vector{Vector{Float64}}[Vector{Float64}[[5.0,5.0],[0.0,0.0],[0.0,2.0],[2.0,2.0],[5.0,5.0]]]]
72-
geotypes = [:MultiPoint,:LineString,:Polygon]
73-
for (i,item) in enumerate(collection)
74-
factcheck_equals(GeoInterface.coordinates(item), coords[i])
75-
@fact GeoInterface.geotype(item) --> geotypes[i]
79+
geomcollection = LibGEOS.GeometryCollection(LibGEOS.geomFromWKT("GEOMETRYCOLLECTION EMPTY"))
80+
collection = GeoInterface.geometries(geomcollection)
81+
@fact length(collection) --> 0
82+
@fact GeoInterface.geotype(geomcollection) --> :GeometryCollection
7683
end
77-
@fact GeoInterface.geotype(geomcollection) --> :GeometryCollection
78-
79-
geomcollection = LibGEOS.GeometryCollection(LibGEOS.geomFromWKT("GEOMETRYCOLLECTION EMPTY"))
80-
collection = GeoInterface.geometries(geomcollection)
81-
@fact length(collection) --> 0
82-
@fact GeoInterface.geotype(geomcollection) --> :GeometryCollection

0 commit comments

Comments
 (0)