mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-12 00:02:09 +00:00
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. [SVN r76514]
This commit is contained in:
@@ -194,7 +194,15 @@ void test_open_ccw()
|
||||
// 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 @@ int test_main(int, char* [])
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -44,11 +44,11 @@ void test_all()
|
||||
", 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> >();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -228,6 +228,20 @@ void test_all()
|
||||
// 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 @@ int test_main(int, char* [])
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
test_empty_input<bg::model::d2::point_xy<int> >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,12 @@ void test_all()
|
||||
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 @@ int test_main(int, char* [])
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
test_empty_input<bg::model::d2::point_xy<int> >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,15 @@ void test_open()
|
||||
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 @@ int test_main(int, char* [])
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
test_empty_input<bg::model::d2::point_xy<int> >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -66,5 +66,20 @@ void test_geometry(std::string const& wkt,
|
||||
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
|
||||
|
||||
@@ -109,23 +109,16 @@ void test_geometry(std::string const& wkt,
|
||||
}
|
||||
|
||||
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" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -140,5 +140,20 @@ void test_geometry(std::string const& wkt1, std::string const& wkt2, double expe
|
||||
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
|
||||
|
||||
@@ -44,5 +44,19 @@ void test_geometry(std::string const& wkt, double expected_length)
|
||||
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
|
||||
|
||||
@@ -47,5 +47,19 @@ void test_geometry(std::string const& wkt, double expected_perimeter)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user