Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76756 - trunk/libs/geometry/test/algorithms
From: barend.gehrels_at_[hidden]
Date: 2012-01-28 13:31:51


Author: barendgehrels
Date: 2012-01-28 13:31:50 EST (Sat, 28 Jan 2012)
New Revision: 76756
URL: http://svn.boost.org/trac/boost/changeset/76756

Log:
Added large-integer tests to area/centroid (tested as well for within,sectionalize,intersections,correct)
Text files modified:
   trunk/libs/geometry/test/algorithms/area.cpp | 20 ++++++++++++++++++++
   trunk/libs/geometry/test/algorithms/centroid.cpp | 30 ++++++++++++++++++++++++++++--
   2 files changed, 48 insertions(+), 2 deletions(-)

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-28 13:31:50 EST (Sat, 28 Jan 2012)
@@ -204,6 +204,24 @@
     test_empty_input(ring_empty);
 }
 
+void test_large_integers()
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
+
+ bg::model::polygon<int_point_type> int_poly;
+ bg::model::polygon<double_point_type> double_poly;
+
+ std::string const polygon_li = "POLYGON((1872000 528000,1872000 192000,1536119 192000,1536000 528000,1200000 528000,1200000 863880,1536000 863880,1872000 863880,1872000 528000))";
+ bg::read_wkt(polygon_li, int_poly);
+ bg::read_wkt(polygon_li, double_poly);
+
+ double int_area = bg::area(int_poly);
+ double double_area = bg::area(double_poly);
+
+ BOOST_CHECK_CLOSE(int_area, double_area, 0.0001);
+}
+
 int test_main(int, char* [])
 {
     test_all<bg::model::point<int, 2, bg::cs::cartesian> >();
@@ -222,6 +240,8 @@
     test_spherical<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
 #endif
 
+ test_large_integers();
+
     test_empty_input<bg::model::d2::point_xy<int> >();
 
     return 0;

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-28 13:31:50 EST (Sat, 28 Jan 2012)
@@ -101,11 +101,34 @@
     test_centroid_exception<bg::model::ring<P> >();
 }
 
+void test_large_integers()
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
+
+ bg::model::polygon<int_point_type> int_poly;
+ bg::model::polygon<double_point_type> double_poly;
+
+ std::string const polygon_li = "POLYGON((1872000 528000,1872000 192000,1536119 192000,1536000 528000,1200000 528000,1200000 863880,1536000 863880,1872000 863880,1872000 528000))";
+ bg::read_wkt(polygon_li, int_poly);
+ bg::read_wkt(polygon_li, double_poly);
+
+ int_point_type int_centroid;
+ double_point_type double_centroid;
+
+ bg::centroid(int_poly, int_centroid);
+ bg::centroid(double_poly, double_centroid);
+
+ int_point_type double_centroid_as_int;
+ bg::assign(int_centroid, double_centroid_as_int);
+
+ BOOST_CHECK_EQUAL(bg::get<0>(int_centroid), bg::get<0>(double_centroid_as_int));
+ BOOST_CHECK_EQUAL(bg::get<1>(int_centroid), bg::get<1>(double_centroid_as_int));
+}
+
 
 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> >();
@@ -119,5 +142,8 @@
     test_3d<boost::tuple<ttmath_big, ttmath_big, ttmath_big> >();
 #endif
 
+ test_large_integers();
+ test_exceptions<bg::model::d2::point_xy<double> >();
+
     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