Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76487 - trunk/libs/geometry/test/algorithms
From: barend.gehrels_at_[hidden]
Date: 2012-01-14 09:19:36


Author: barendgehrels
Date: 2012-01-14 09:19:35 EST (Sat, 14 Jan 2012)
New Revision: 76487
URL: http://svn.boost.org/trac/boost/changeset/76487

Log:
Added/fixed unit test for centroid exceptions
Text files modified:
   trunk/libs/geometry/test/algorithms/centroid.cpp | 14 ++++++++++----
   trunk/libs/geometry/test/algorithms/test_centroid.hpp | 16 ++++++++++++++++
   2 files changed, 26 insertions(+), 4 deletions(-)

Modified: trunk/libs/geometry/test/algorithms/centroid.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/centroid.cpp (original)
+++ trunk/libs/geometry/test/algorithms/centroid.cpp 2012-01-14 09:19:35 EST (Sat, 14 Jan 2012)
@@ -73,10 +73,6 @@
 
     test_centroid<bg::model::box<P> >("POLYGON((1 2,3 4))", 2, 3);
     test_centroid<P>("POINT(3 3)", 3, 3);
-
- //test_centroid_exception<bg::model::linestring<P> >("LINESTRING EMPTY");
-/// test_centroid_exception<bg::model::polygon<P> >("POLYGON EMPTY");
-// test_centroid_exception<bg::model::ring<P> >("POLYGON EMPTY");
 }
 
 
@@ -97,9 +93,19 @@
                                              4.9202312983547678, 0.69590937869808345, 1.2632138719797417, 6.0468332057401986, 23.082402715244868);
 }
 
+template <typename P>
+void test_exceptions()
+{
+ test_centroid_exception<bg::model::linestring<P> >();
+ test_centroid_exception<bg::model::polygon<P> >();
+ test_centroid_exception<bg::model::ring<P> >();
+}
+
 
 int test_main(int, char* [])
 {
+ test_exceptions<bg::model::d2::point_xy<double> >();
+
     test_2d<bg::model::d2::point_xy<double> >();
     test_2d<boost::tuple<float, float> >();
     test_2d<bg::model::d2::point_xy<float> >();

Modified: trunk/libs/geometry/test/algorithms/test_centroid.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_centroid.hpp (original)
+++ trunk/libs/geometry/test/algorithms/test_centroid.hpp 2012-01-14 09:19:35 EST (Sat, 14 Jan 2012)
@@ -79,5 +79,21 @@
 #endif
 }
 
+template <typename Geometry>
+void test_centroid_exception()
+{
+ Geometry geometry;
+ try
+ {
+ typename bg::point_type<Geometry>::type c;
+ bg::centroid(geometry, c);
+ }
+ catch(bg::centroid_exception const& )
+ {
+ return;
+ }
+ BOOST_CHECK_MESSAGE(false, "A centroid_exception should have been thrown" );
+}
+
 
 #endif


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