// 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 #include #ifdef BOOST_GEOMETRY_TEST_QUARANTINED struct not_two { template bool operator()(P const& p) const { return boost::geometry::get<0>(p) != 2.0; } }; struct sum_not_five { template bool operator()(P const& p1, P const& p2) const { return boost::geometry::get<0>(p1) + boost::geometry::get<0>(p2) != 5.0; } }; #endif template void test_range_adaptor() { bg::model::linestring

ls; bg::read_wkt("LINESTRING(1 1,2 2,3 3,4 4)", ls); { std::ostringstream out; out << bg::wkt(ls); BOOST_CHECK_EQUAL(out.str(), "LINESTRING(1 1,2 2,3 3,4 4)"); } { std::ostringstream out; out << bg::wkt(ls | boost::adaptors::reversed); BOOST_CHECK_EQUAL(out.str(), "LINESTRING(4 4,3 3,2 2,1 1)"); } { std::ostringstream out; out << bg::wkt(ls | boost::adaptors::strided(2)); BOOST_CHECK_EQUAL(out.str(), "LINESTRING(1 1,3 3)"); } { std::ostringstream out; out << bg::wkt(ls | boost::adaptors::sliced(1,3)); BOOST_CHECK_EQUAL(out.str(), "LINESTRING(2 2,3 3)"); } #ifdef BOOST_GEOMETRY_TEST_QUARANTINED // range filter adaptor does not support boost::size() // This makes it in practice not applicable, boost::geometry calls boost::size // in most if not all algorithms { std::ostringstream out; out << bg::wkt(ls | boost::adaptors::filtered(not_two())); BOOST_CHECK_EQUAL(out.str(), "LINESTRING(1 1,3 3,4 4)"); } { std::ostringstream out; out << bg::wkt(ls | boost::adaptors::adjacent_filtered(sum_not_five())); BOOST_CHECK_EQUAL(out.str(), "LINESTRING(1 1,3 3,4 4)"); } { bg::model::linestring

ls2; bg::read_wkt("LINESTRING(1 1,1 1,2 2,3 3,3 3,4 4)", ls2); std::ostringstream out; // uniqued needs == operator, equals //out << bg::wkt(ls | boost::adaptors::uniqued); //BOOST_CHECK_EQUAL(out.str(), "LINESTRING(1 1,2 2,3 3,4 4)"); } #endif } template void test_all() { test_range_adaptor

(); } int test_main(int, char* []) { test_all >(); test_all >(); return 0; }