// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // This file was modified by Oracle on 2014, 2015. // Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-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 #include #include #include #include #include #include #include BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector) BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque) template struct do_checks { template static inline void apply(G const& geometry, std::size_t size1, std::size_t = 0, std::size_t = 0) { BOOST_CHECK_EQUAL(bg::num_points(geometry), size1); } }; template<> struct do_checks { template static inline void apply(G const& geometry, std::size_t size1, std::size_t size2 = 0, std::size_t size3 = 0) { do_checks::apply(geometry, size1); BOOST_CHECK_EQUAL(bg::num_points(geometry[0]), size2); BOOST_CHECK_EQUAL(bg::num_points(geometry[1]), size3); } }; template struct test_geometry { template static inline void apply(G& geometry, bool check) { typedef typename bg::point_type::type P; typedef do_checks checks; bg::append(geometry, bg::make_zero

(), -1, 0); if (check) { checks::apply(geometry, 1u, 1u, 0u); } // Append a range std::vector

v; v.push_back(bg::make_zero

()); v.push_back(bg::make_zero

()); bg::append(geometry, v, -1, 1); if (check) { checks::apply(geometry, 3u, 1u, 2u); } bg::clear(geometry); if (check) { do_checks::apply(geometry, 0u); } } }; template void test_geometry_and_variant(bool check = true) { G geometry; boost::variant variant_geometry = G(); test_geometry::apply(geometry, check); test_geometry::apply(variant_geometry, check); } template void test_multigeometry_and_variant(bool check = true) { typedef typename boost::range_value::type G; G geometry; MG multigeometry; bg::traits::push_back::apply(multigeometry, geometry); bg::traits::push_back::apply(multigeometry, geometry); boost::variant variant_multigeometry = multigeometry; test_geometry::apply(multigeometry, check); test_geometry::apply(variant_multigeometry, check); } template void test_all() { test_geometry_and_variant

(false); test_geometry_and_variant >(false); test_geometry_and_variant >(false); test_geometry_and_variant >(); test_geometry_and_variant >(); test_geometry_and_variant >(); test_geometry_and_variant >(); test_multigeometry_and_variant < bg::model::multi_linestring > >(); test_multigeometry_and_variant < bg::model::multi_polygon > >(); test_geometry_and_variant >(); test_geometry_and_variant >(); } int test_main(int, char* []) { test_all(); test_all >(); test_all >(); test_all >(); #ifdef HAVE_TTMATH test_all >(); #endif return 0; }