11#include " ../examples/utils.hpp"
22#include < algorithm>
33#include < catch.hpp>
4+ #include < utility>
45#include < cmath>
56#include < delaunator-header-only.hpp>
67
78namespace {
89
9- constexpr double EPSILON = std::numeric_limits <double >::epsilon();
10-
11- inline void validate ( const std::vector< double >& coords, const double e) {
10+ inline std::pair <double , double >
11+ validateImpl ( const std::vector< double >& coords)
12+ {
1213 delaunator::Delaunator d (coords);
1314
1415 // validate halfedges
@@ -31,13 +32,20 @@ inline void validate(const std::vector<double>& coords, const double e) {
3132 const double cy = coords[2 * d.triangles [i + 2 ] + 1 ];
3233 sum += std::fabs ((by - ay) * (cx - bx) - (bx - ax) * (cy - by));
3334 }
34- // printf("comparing %f == %f \n", triangles_area, hull_area);
35- REQUIRE (sum == Approx (hull_area).epsilon (e));
35+ return { sum, hull_area };
3636}
3737
3838inline void validate (const std::vector<double >& coords) {
39- validate (coords, EPSILON);
39+ auto result = validateImpl (coords);
40+ REQUIRE (result.first == Approx (result.second ));
41+ }
42+
43+ /* *
44+ inline void validate(const std::vector<double>& coords, double e) {
45+ auto result = validateImpl(coords);
46+ REQUIRE(result.first == Approx(result.second).epsilon(e));
4047}
48+ **/
4149
4250struct multiply {
4351 double factor;
@@ -101,7 +109,8 @@ TEST_CASE("robustness", "[Delaunator]") {
101109 validate (coords_result);
102110
103111 std::transform (coords.begin (), coords.end (), coords_result.begin (), multiply{ 1e2 });
104- validate (coords_result, EPSILON * 2.0 ); // TODO: missing triangle?
112+ // validate(coords_result, EPSILON * 2.0); //TODO: missing triangle?
113+ validate (coords_result);
105114
106115 std::transform (coords.begin (), coords.end (), coords_result.begin (), multiply{ 1e9 });
107116 validate (coords_result);
0 commit comments