Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76514 - in trunk: boost/geometry/algorithms boost/geometry/algorithms/detail boost/geometry/core boost/geometry/multi/algorithms libs/geometry/test/algorithms libs/geometry/test/multi/algorithms
From: barend.gehrels_at_[hidden]
Date: 2012-01-15 08:23:10


Author: barendgehrels
Date: 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
New Revision: 76514
URL: http://svn.boost.org/trac/boost/changeset/76514

Log:
Added empty_input_exception and applied for distance, length, area, perimeter
Removed exception for convex_hull because that can be handled (for now) by leaving output empty. To be decided what is the definitive (additional, optional) behaviour.
Added:
   trunk/boost/geometry/algorithms/detail/throw_on_empty_input.hpp (contents, props changed)
Text files modified:
   trunk/boost/geometry/algorithms/area.hpp | 6 +++++-
   trunk/boost/geometry/algorithms/convex_hull.hpp | 31 +------------------------------
   trunk/boost/geometry/algorithms/distance.hpp | 4 ++++
   trunk/boost/geometry/algorithms/length.hpp | 5 +++++
   trunk/boost/geometry/algorithms/perimeter.hpp | 5 +++++
   trunk/boost/geometry/core/exception.hpp | 26 ++++++++++++++++++++++++++
   trunk/boost/geometry/multi/algorithms/distance.hpp | 11 +++++------
   trunk/libs/geometry/test/algorithms/area.cpp | 10 ++++++++++
   trunk/libs/geometry/test/algorithms/convex_hull.cpp | 10 +++++-----
   trunk/libs/geometry/test/algorithms/distance.cpp | 16 ++++++++++++++++
   trunk/libs/geometry/test/algorithms/length.cpp | 8 ++++++++
   trunk/libs/geometry/test/algorithms/perimeter.cpp | 11 +++++++++++
   trunk/libs/geometry/test/algorithms/test_area.hpp | 15 +++++++++++++++
   trunk/libs/geometry/test/algorithms/test_convex_hull.hpp | 21 +++++++--------------
   trunk/libs/geometry/test/algorithms/test_distance.hpp | 15 +++++++++++++++
   trunk/libs/geometry/test/algorithms/test_length.hpp | 14 ++++++++++++++
   trunk/libs/geometry/test/algorithms/test_perimeter.hpp | 14 ++++++++++++++
   trunk/libs/geometry/test/multi/algorithms/multi_convex_hull.cpp | 6 +++---
   trunk/libs/geometry/test/multi/algorithms/multi_distance.cpp | 21 +++++++++++++++++++++
   19 files changed, 190 insertions(+), 59 deletions(-)

Modified: trunk/boost/geometry/algorithms/area.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/area.hpp (original)
+++ trunk/boost/geometry/algorithms/area.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -19,7 +19,6 @@
 #include <boost/range/functions.hpp>
 #include <boost/range/metafunctions.hpp>
 
-
 #include <boost/geometry/core/closure.hpp>
 #include <boost/geometry/core/exterior_ring.hpp>
 #include <boost/geometry/core/interior_rings.hpp>
@@ -30,6 +29,7 @@
 
 #include <boost/geometry/algorithms/detail/calculate_null.hpp>
 #include <boost/geometry/algorithms/detail/calculate_sum.hpp>
+#include <boost/geometry/algorithms/detail/throw_on_empty_input.hpp>
 
 #include <boost/geometry/strategies/area.hpp>
 #include <boost/geometry/strategies/default_area_result.hpp>
@@ -241,6 +241,8 @@
             point_type
>::type strategy_type;
 
+ detail::throw_on_empty_input(geometry);
+
     return dispatch::area
         <
             Geometry
@@ -277,6 +279,8 @@
 {
     concept::check<Geometry const>();
 
+ detail::throw_on_empty_input(geometry);
+
     return dispatch::area
         <
             Geometry,

Modified: trunk/boost/geometry/algorithms/convex_hull.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/convex_hull.hpp (original)
+++ trunk/boost/geometry/algorithms/convex_hull.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -35,33 +35,6 @@
 namespace boost { namespace geometry
 {
 
-#if ! defined(BOOST_GEOMETRY_CONVEX_HULL_NO_THROW)
-
-/*!
-\brief Convex Hull Exception
-\ingroup convex_hull
-\details The convex_hull_exception is thrown if the free convex hull function is called with
- geometries for which the hull cannot be calculated. For example: a linestring
- without points, a polygon without points, an empty multi-geometry.
-\qbk{
-[heading See also]
-\* [link geometry.reference.algorithms.convex_hull the convex_hull function]
-}
-
- */
-class convex_hull_exception : public geometry::exception
-{
-public:
-
- inline convex_hull_exception() {}
-
- virtual char const* what() const throw()
- {
- return "Boost.Geometry Convex Hull calculation exception";
- }
-};
-
-#endif
 
 #ifndef DOXYGEN_NO_DETAIL
 namespace detail { namespace convex_hull
@@ -204,9 +177,7 @@
 
     if (geometry::num_points(geometry) == 0)
     {
-#if ! defined(BOOST_GEOMETRY_CONVEX_HULL_NO_THROW)
- throw convex_hull_exception();
-#endif
+ // Leave output empty
         return;
     }
 

Added: trunk/boost/geometry/algorithms/detail/throw_on_empty_input.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/geometry/algorithms/detail/throw_on_empty_input.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -0,0 +1,43 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// 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)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_THROW_ON_EMPTY_INPUT_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_THROW_ON_EMPTY_INPUT_HPP
+
+#include <boost/geometry/core/exception.hpp>
+#include <boost/geometry/algorithms/num_points.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename Geometry>
+inline void throw_on_empty_input(Geometry const& geometry)
+{
+#if ! defined(BOOST_GEOMETRY_EMPTY_INPUT_NO_THROW)
+ if (geometry::num_points(geometry) == 0)
+ {
+ throw empty_input_exception();
+ }
+#endif
+}
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_THROW_ON_EMPTY_INPUT_HPP
+

Modified: trunk/boost/geometry/algorithms/distance.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/distance.hpp (original)
+++ trunk/boost/geometry/algorithms/distance.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -25,6 +25,7 @@
 #include <boost/geometry/core/tag_cast.hpp>
 
 #include <boost/geometry/algorithms/not_implemented.hpp>
+#include <boost/geometry/algorithms/detail/throw_on_empty_input.hpp>
 
 #include <boost/geometry/geometries/segment.hpp>
 #include <boost/geometry/geometries/concepts/check.hpp>
@@ -549,6 +550,9 @@
 {
     concept::check<Geometry1 const>();
     concept::check<Geometry2 const>();
+
+ detail::throw_on_empty_input(geometry1);
+ detail::throw_on_empty_input(geometry2);
 
     return dispatch::distance
                <

Modified: trunk/boost/geometry/algorithms/length.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/length.hpp (original)
+++ trunk/boost/geometry/algorithms/length.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -28,6 +28,7 @@
 
 #include <boost/geometry/algorithms/assign.hpp>
 #include <boost/geometry/algorithms/detail/calculate_null.hpp>
+#include <boost/geometry/algorithms/detail/throw_on_empty_input.hpp>
 #include <boost/geometry/views/closeable_view.hpp>
 #include <boost/geometry/strategies/distance.hpp>
 #include <boost/geometry/strategies/default_length_result.hpp>
@@ -151,6 +152,8 @@
 {
     concept::check<Geometry const>();
 
+ detail::throw_on_empty_input(geometry);
+
     typedef typename strategy::distance::services::default_strategy
         <
             point_tag, typename point_type<Geometry>::type
@@ -185,6 +188,8 @@
 {
     concept::check<Geometry const>();
 
+ detail::throw_on_empty_input(geometry);
+
     return dispatch::length
         <
             typename tag<Geometry>::type,

Modified: trunk/boost/geometry/algorithms/perimeter.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/perimeter.hpp (original)
+++ trunk/boost/geometry/algorithms/perimeter.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -22,6 +22,7 @@
 #include <boost/geometry/algorithms/length.hpp>
 #include <boost/geometry/algorithms/detail/calculate_null.hpp>
 #include <boost/geometry/algorithms/detail/calculate_sum.hpp>
+#include <boost/geometry/algorithms/detail/throw_on_empty_input.hpp>
 
 
 namespace boost { namespace geometry
@@ -97,6 +98,8 @@
             point_tag, point_type
>::type strategy_type;
 
+ detail::throw_on_empty_input(geometry);
+
     return dispatch::perimeter
         <
             typename tag<Geometry>::type,
@@ -125,6 +128,8 @@
 {
     concept::check<Geometry const>();
 
+ detail::throw_on_empty_input(geometry);
+
     return dispatch::perimeter
         <
             typename tag<Geometry>::type,

Modified: trunk/boost/geometry/core/exception.hpp
==============================================================================
--- trunk/boost/geometry/core/exception.hpp (original)
+++ trunk/boost/geometry/core/exception.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -29,6 +29,32 @@
 {};
 
 
+/*!
+\brief Empty Input Exception
+\ingroup core
+\details The empty_input_exception is thrown if free functions, e.g. distance,
+ are called with empty geometries, e.g. a linestring
+ without points, a polygon without points, an empty multi-geometry.
+\qbk{
+[heading See also]
+\* [link geometry.reference.algorithms.area the area function]
+\* [link geometry.reference.algorithms.distance the distance function]
+\* [link geometry.reference.algorithms.length the length function]
+}
+ */
+class empty_input_exception : public geometry::exception
+{
+public:
+
+ inline empty_input_exception() {}
+
+ virtual char const* what() const throw()
+ {
+ return "Boost.Geometry Empty-Input exception";
+ }
+};
+
+
 }} // namespace boost::geometry
 
 #endif // BOOST_GEOMETRY_CORE_EXCEPTION_HPP

Modified: trunk/boost/geometry/multi/algorithms/distance.hpp
==============================================================================
--- trunk/boost/geometry/multi/algorithms/distance.hpp (original)
+++ trunk/boost/geometry/multi/algorithms/distance.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -23,6 +23,7 @@
 #include <boost/geometry/multi/core/point_type.hpp>
 
 #include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/multi/algorithms/num_points.hpp>
 #include <boost/geometry/util/select_coordinate_type.hpp>
 
 
@@ -49,12 +50,12 @@
                 MultiGeometry const& multi,
                 Strategy const& strategy)
     {
+ return_type mindist = return_type();
         bool first = true;
- return_type mindist;
 
         for(typename range_iterator<MultiGeometry const>::type it = boost::begin(multi);
                 it != boost::end(multi);
- ++it)
+ ++it, first = false)
         {
             return_type dist = dispatch::distance
                 <
@@ -67,7 +68,6 @@
             {
                 mindist = dist;
             }
- first = false;
         }
 
         return mindist;
@@ -88,12 +88,12 @@
     static inline return_type apply(Multi1 const& multi1,
                 Multi2 const& multi2, Strategy const& strategy)
     {
+ return_type mindist = return_type();
         bool first = true;
- return_type mindist;
 
         for(typename range_iterator<Multi1 const>::type it = boost::begin(multi1);
                 it != boost::end(multi1);
- ++it)
+ ++it, first = false)
         {
             return_type dist = distance_single_to_multi
                 <
@@ -105,7 +105,6 @@
             {
                 mindist = dist;
             }
- first = false;
         }
 
         return mindist;

Modified: trunk/libs/geometry/test/algorithms/area.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/area.cpp (original)
+++ trunk/libs/geometry/test/algorithms/area.cpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -194,7 +194,15 @@
     // Note the triangular testcase used in CCW is not sensible for open/close
 }
 
+template <typename P>
+void test_empty_input()
+{
+ bg::model::polygon<P> poly_empty;
+ bg::model::ring<P> ring_empty;
 
+ test_empty_input(poly_empty);
+ test_empty_input(ring_empty);
+}
 
 int test_main(int, char* [])
 {
@@ -214,5 +222,7 @@
     test_spherical<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
 #endif
 
+ test_empty_input<bg::model::d2::point_xy<int> >();
+
     return 0;
 }

Modified: trunk/libs/geometry/test/algorithms/convex_hull.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/convex_hull.cpp (original)
+++ trunk/libs/geometry/test/algorithms/convex_hull.cpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -44,11 +44,11 @@
         ", 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))",
                 12, 8, 5.245);
 
- // Waits for next cycle test_geometry<bg::model::box<P> >("box(0 0,2 2)", 5, 5, 4);
-
- test_convex_hull_exception<bg::model::linestring<P> >();
- test_convex_hull_exception<bg::model::polygon<P> >();
- test_convex_hull_exception<bg::model::ring<P> >();
+ test_geometry<bg::model::box<P> >("box(0 0,2 2)", 4, 5, 4);
+
+ test_empty_input<bg::model::linestring<P> >();
+ test_empty_input<bg::model::ring<P> >();
+ test_empty_input<bg::model::polygon<P> >();
 }
 
 

Modified: trunk/libs/geometry/test/algorithms/distance.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/distance.cpp (original)
+++ trunk/libs/geometry/test/algorithms/distance.cpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -228,6 +228,20 @@
     // test_geometry<P, boost::array<P, 2> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
 
     test_geometry<P, test::wrapped_boost_array<P, 2> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
+
+}
+
+template <typename P>
+void test_empty_input()
+{
+ P p;
+ bg::model::linestring<P> line_empty;
+ bg::model::polygon<P> poly_empty;
+ bg::model::ring<P> ring_empty;
+
+ test_empty_input(p, line_empty);
+ test_empty_input(p, poly_empty);
+ test_empty_input(p, ring_empty);
 }
 
 int test_main(int, char* [])
@@ -248,5 +262,7 @@
     test_all<bg::model::d2::point_xy<ttmath_big> >();
 #endif
 
+ test_empty_input<bg::model::d2::point_xy<int> >();
+
     return 0;
 }

Modified: trunk/libs/geometry/test/algorithms/length.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/length.cpp (original)
+++ trunk/libs/geometry/test/algorithms/length.cpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -33,6 +33,12 @@
     test_geometry<bg::model::polygon<P> >("POLYGON((0 0,0 1,1 1,1 0,0 0))", 0);
 }
 
+template <typename P>
+void test_empty_input()
+{
+ test_empty_input(bg::model::linestring<P>());
+}
+
 int test_main(int, char* [])
 {
     test_all<bg::model::d2::point_xy<int> >();
@@ -43,5 +49,7 @@
     test_all<bg::model::d2::point_xy<ttmath_big> >();
 #endif
 
+ test_empty_input<bg::model::d2::point_xy<int> >();
+
     return 0;
 }

Modified: trunk/libs/geometry/test/algorithms/perimeter.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/perimeter.cpp (original)
+++ trunk/libs/geometry/test/algorithms/perimeter.cpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -35,6 +35,15 @@
     test_geometry<open_polygon>("POLYGON((0 0,0 1,1 1,1 0))", 4);
 }
 
+template <typename P>
+void test_empty_input()
+{
+ bg::model::polygon<P> poly_empty;
+ bg::model::ring<P> ring_empty;
+
+ test_empty_input(poly_empty);
+ test_empty_input(ring_empty);
+}
 
 int test_main(int, char* [])
 {
@@ -48,5 +57,7 @@
     test_all<bg::model::d2::point_xy<ttmath_big> >();
 #endif
 
+ test_empty_input<bg::model::d2::point_xy<int> >();
+
     return 0;
 }

Modified: trunk/libs/geometry/test/algorithms/test_area.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_area.hpp (original)
+++ trunk/libs/geometry/test/algorithms/test_area.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -66,5 +66,20 @@
     test_area(geometry, expected_area);
 }
 
+template <typename Geometry>
+void test_empty_input(Geometry const& geometry)
+{
+ try
+ {
+ typename bg::default_area_result<Geometry>::type area
+ = bg::area(geometry);
+ }
+ catch(bg::empty_input_exception const& )
+ {
+ return;
+ }
+ BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" );
+}
+
 
 #endif

Modified: trunk/libs/geometry/test/algorithms/test_convex_hull.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_convex_hull.hpp (original)
+++ trunk/libs/geometry/test/algorithms/test_convex_hull.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -109,23 +109,16 @@
 }
 
 template <typename Geometry>
-void test_convex_hull_exception()
+void test_empty_input()
 {
     Geometry geometry;
- try
- {
- bg::model::polygon
- <
- typename bg::point_type<Geometry>::type
- > hull;
+ bg::model::polygon
+ <
+ typename bg::point_type<Geometry>::type
+ > hull;
 
- bg::convex_hull(geometry, hull);
- }
- catch(bg::convex_hull_exception const& )
- {
- return;
- }
- BOOST_CHECK_MESSAGE(false, "A convex_hull_exception should have been thrown" );
+ bg::convex_hull(geometry, hull);
+ BOOST_CHECK_MESSAGE(bg::num_points(hull) == 0, "Output convex hull should be empty" );
 }
 
 

Modified: trunk/libs/geometry/test/algorithms/test_distance.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_distance.hpp (original)
+++ trunk/libs/geometry/test/algorithms/test_distance.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -140,5 +140,20 @@
     test_distance(geometry1, geometry2, expected_distance);
 }
 
+template <typename Geometry1, typename Geometry2>
+void test_empty_input(Geometry1 const& geometry1, Geometry2 const& geometry2)
+{
+ try
+ {
+ typename bg::default_distance_result<Geometry1>::type distance
+ = bg::distance(geometry1, geometry2);
+ }
+ catch(bg::empty_input_exception const& )
+ {
+ return;
+ }
+ BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" );
+}
+
 
 #endif

Modified: trunk/libs/geometry/test/algorithms/test_length.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_length.hpp (original)
+++ trunk/libs/geometry/test/algorithms/test_length.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -44,5 +44,19 @@
     test_length(geometry, expected_length);
 }
 
+template <typename Geometry>
+void test_empty_input(Geometry const& geometry)
+{
+ try
+ {
+ typename bg::default_length_result<Geometry>::type length
+ = bg::length(geometry);
+ }
+ catch(bg::empty_input_exception const& )
+ {
+ return;
+ }
+ BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" );
+}
 
 #endif

Modified: trunk/libs/geometry/test/algorithms/test_perimeter.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_perimeter.hpp (original)
+++ trunk/libs/geometry/test/algorithms/test_perimeter.hpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -47,5 +47,19 @@
     test_perimeter(geometry, expected_perimeter);
 }
 
+template <typename Geometry>
+void test_empty_input(Geometry const& geometry)
+{
+ try
+ {
+ typename bg::default_distance_result<Geometry>::type peri
+ = bg::perimeter(geometry);
+ }
+ catch(bg::empty_input_exception const& )
+ {
+ return;
+ }
+ BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" );
+}
 
 #endif

Modified: trunk/libs/geometry/test/multi/algorithms/multi_convex_hull.cpp
==============================================================================
--- trunk/libs/geometry/test/multi/algorithms/multi_convex_hull.cpp (original)
+++ trunk/libs/geometry/test/multi/algorithms/multi_convex_hull.cpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -53,9 +53,9 @@
     test_geometry<ml>("multilinestring((2 4, 3 4, 3 5), (4 3,4 4,5 4))", 6, 5, 3.0);
     test_geometry<mpoly>("multipolygon(((1 4,1 6,2 5,3 5,4 6,4 4,1 4)), ((4 2,4 3,6 3,6 2,4 2)))", 12, 7, 14.0);
 
- test_convex_hull_exception<mp>();
- test_convex_hull_exception<ml>();
- test_convex_hull_exception<mpoly>();
+ test_empty_input<mp>();
+ test_empty_input<ml>();
+ test_empty_input<mpoly>();
 }
 
 

Modified: trunk/libs/geometry/test/multi/algorithms/multi_distance.cpp
==============================================================================
--- trunk/libs/geometry/test/multi/algorithms/multi_distance.cpp (original)
+++ trunk/libs/geometry/test/multi/algorithms/multi_distance.cpp 2012-01-15 08:23:08 EST (Sun, 15 Jan 2012)
@@ -10,6 +10,8 @@
 
 #include <geometry_test_common.hpp>
 
+#include <algorithms/test_distance.hpp>
+
 #include <boost/geometry/algorithms/distance.hpp>
 #include <boost/geometry/io/wkt/read.hpp>
 
@@ -128,6 +130,23 @@
     test_distance<mp2, P2>(pythagoras<P2, P2>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0);
 }
 
+template <typename P>
+void test_empty_input()
+{
+ P p;
+ bg::model::multi_point<P> mp_empty;
+ bg::model::multi_linestring<bg::model::linestring<P> > ml_empty;
+
+ test_empty_input(p, mp_empty);
+ test_empty_input(p, ml_empty);
+ test_empty_input(mp_empty, mp_empty);
+
+ // Test behaviour if one of the inputs is empty
+ bg::model::multi_point<P> mp;
+ mp.push_back(p);
+ test_empty_input(mp_empty, mp);
+ test_empty_input(mp, mp_empty);
+}
 
 
 int test_main( int , char* [] )
@@ -146,5 +165,7 @@
     test_mixed<bg::model::d2::point_xy<ttmath_big>, bg::model::d2::point_xy<double> >();
 #endif
 
+ test_empty_input<bg::model::d2::point_xy<int> >();
+
     return 0;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk