// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2010-2012 Barend Gehrels, 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 #include BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) template void test_forward_or_reverse(Range const& range, std::string const& expected) { typedef typename bg::reversible_view < Range const, Direction >::type view_type; view_type view(range); bool first = true; std::ostringstream out; for (typename boost::range_iterator::type it = boost::begin(view); it != boost::end(view); ++it, first = false) { out << (first ? "" : " ") << bg::dsv(*it); } BOOST_CHECK_EQUAL(out.str(), expected); } template void test_geometry(std::string const& wkt, std::string const& expected_forward, std::string const& expected_reverse) { Geometry geo; bg::read_wkt(wkt, geo); test_forward_or_reverse(geo, expected_forward); test_forward_or_reverse(geo, expected_reverse); } template void test_all() { test_geometry >( "linestring(1 1,2 2,3 3)", "(1, 1) (2, 2) (3, 3)", "(3, 3) (2, 2) (1, 1)"); } int test_main(int, char* []) { test_all >(); test_all >(); test_all >(); return 0; }