Skip to content

Commit

Permalink
Add test for invalid value warning from GEOSProject and GEOSProjectNo…
Browse files Browse the repository at this point in the history
…rmalized
  • Loading branch information
mwtoews committed Nov 22, 2023
1 parent b3415ca commit 34b29f8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/unit/capi/GEOSProjectTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,25 @@ void object::test<4>
ensure_equals(dist_norm, 0.0);
}

// Test invalid value warning
// https://github.com/shapely/shapely/issues/1796
template<>
template<>
void object::test<5>
()
{
geom1_ = GEOSGeomFromWKT("LINESTRING (0 0, 1 1, 1 1, 2 2)");
geom2_ = GEOSGeomFromWKT("POINT (0 1)");

std::feclearexcept(FE_ALL_EXCEPT);
double dist = GEOSProject(geom1_, geom2_);
ensure("FE_INVALID raised", !std::fetestexcept(FE_INVALID));
ensure_equals("GEOSProject", dist, 0.7071, 0.0001);

std::feclearexcept(FE_ALL_EXCEPT);
double dist_norm = GEOSProjectNormalized(geom1_, geom2_);
ensure("FE_INVALID raised", !std::fetestexcept(FE_INVALID));
ensure_equals("GEOSProjectNormalized", dist_norm, 0.25);
}

} // namespace tut

0 comments on commit 34b29f8

Please sign in to comment.