#include "catch.hpp" // boost #include #include #include #include #include // helper namespace to ensure correct functionality namespace aux{ namespace adl{ using std::begin; using std::end; template auto do_begin(T& v) -> decltype(begin(v)); template auto do_end(T& v) -> decltype(end(v)); } // adl:: template using zipper_it = boost::zip_iterator>; template T const& as_const(T const& v){ return v; } } // aux:: template auto zip_begin(Conts&... conts) -> aux::zipper_it { using std::begin; return {boost::make_tuple(begin(conts)...)}; } template auto zip_end(Conts&... conts) -> aux::zipper_it { using std::end; return {boost::make_tuple(end(conts)...)}; } template auto zip_range(Conts&... conts) -> boost::iterator_range { return {zip_begin(conts...), zip_end(conts...)}; } // for const access template auto zip_cbegin(Conts&... conts) -> decltype(zip_begin(aux::as_const(conts)...)) { using std::begin; return zip_begin(aux::as_const(conts)...); } template auto zip_cend(Conts&... conts) -> decltype(zip_end(aux::as_const(conts)...)) { using std::end; return zip_end(aux::as_const(conts)...); } template auto zip_crange(Conts&... conts) -> decltype(zip_range(aux::as_const(conts)...)) { return zip_range(aux::as_const(conts)...); } // mapnik #include #include using namespace mapnik::geometry; struct geometry_equal_visitor { template void operator() (T1 const&, T2 const&) { // comparing two different types! REQUIRE(false); } void operator() (geometry_empty const&, geometry_empty const&) { REQUIRE(true); } void operator() (point const& p1, point const& p2) { REQUIRE(p1.x == Approx(p2.x)); REQUIRE(p1.y == Approx(p2.y)); } void operator() (line_string const& ls1, line_string const& ls2) { if (ls1.size() != ls2.size()) { REQUIRE(false); } for(auto const& p : zip_crange(ls1, ls2)) { REQUIRE(p.get<0>().x == Approx(p.get<1>().x)); REQUIRE(p.get<0>().y == Approx(p.get<1>().y)); } } void operator() (polygon const& p1, polygon const& p2) { (*this)(static_cast(p1.exterior_ring), static_cast(p2.exterior_ring)); if (p1.interior_rings.size() != p2.interior_rings.size()) { REQUIRE(false); } for (auto const& p : zip_crange(p1.interior_rings, p2.interior_rings)) { (*this)(static_cast(p.get<0>()),static_cast(p.get<1>())); } } void operator() (multi_point const& mp1, multi_point const& mp2) { (*this)(static_cast(mp1), static_cast(mp2)); } }; void assert_g_equal(geometry const& g1, geometry const& g2) { return mapnik::util::apply_visitor(geometry_equal_visitor(), g1, g2); } template void assert_g_equal(T const& g1, T const& g2) { return geometry_equal_visitor()(g1,g2); }