// Boost.Geometry (aka GGL, Generic Geometry Library) test file // // Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include #include #include #include template void test_optionally_closing(Range const& range, std::string const& expected) { typedef boost::geometry::closeable_view view_type; typedef typename boost::range_iterator::type iterator; view_type view(range); bool first = true; std::ostringstream out; iterator end = boost::end(view); for (iterator it = boost::begin(view); it != end; ++it, first = false) { out << (first ? "" : " ") << boost::geometry::dsv(*it); } BOOST_CHECK_EQUAL(out.str(), expected); } template void test_geometry(std::string const& wkt, std::string const& expected_false, std::string const& expected_true) { namespace bg = boost::geometry; Geometry geo; bg::read_wkt(wkt, geo); test_optionally_closing(geo, expected_false); test_optionally_closing(geo, expected_true); } template void test_all() { test_geometry >( "POLYGON((1 1,1 4,4 4,4 1))", "(1, 1) (1, 4) (4, 4) (4, 1)", "(1, 1) (1, 4) (4, 4) (4, 1) (1, 1)"); } int test_main(int, char* []) { namespace bg = boost::geometry; test_all(); test_all >(); test_all >(); return 0; }