$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r85480 - in trunk/libs/geometry/test: . algorithms
From: barend.gehrels_at_[hidden]
Date: 2013-08-26 17:15:48
Author: barendgehrels
Date: 2013-08-26 17:15:47 EDT (Mon, 26 Aug 2013)
New Revision: 85480
URL: http://svn.boost.org/trac/boost/changeset/85480
Log:
[geometry] fixes in unit-test, uncommented one testcase, enabled for 3 of 4 polygon types. Added convenience function to list type in case of errors
Text files modified: 
   trunk/libs/geometry/test/algorithms/intersection.cpp      |    25 +++++++++++++++----------               
   trunk/libs/geometry/test/algorithms/test_difference.hpp   |     4 ++--                                    
   trunk/libs/geometry/test/algorithms/test_intersection.hpp |     6 +++---                                  
   trunk/libs/geometry/test/algorithms/test_union.hpp        |     2 +-                                      
   trunk/libs/geometry/test/geometry_test_common.hpp         |    37 ++++++++++++++++++++++++++-----------   
   5 files changed, 47 insertions(+), 27 deletions(-)
Modified: trunk/libs/geometry/test/algorithms/intersection.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/intersection.cpp	Mon Aug 26 17:02:18 2013	(r85479)
+++ trunk/libs/geometry/test/algorithms/intersection.cpp	2013-08-26 17:15:47 EDT (Mon, 26 Aug 2013)	(r85480)
@@ -166,6 +166,9 @@
         3, 0, 1.5);
 
     typedef typename bg::coordinate_type<Polygon>::type ct;
+    bool const ccw = bg::point_order<Polygon>::value == bg::counterclockwise;
+    bool const open = bg::closure<Polygon>::value == bg::open;
+
 
 #ifdef TEST_ISOVIST
 #ifdef _MSC_VER
@@ -182,16 +185,18 @@
 
     //std::cout << typeid(ct).name() << std::endl;
 
-    // Pointcount for ttmath/double (both 5) or float (4)
-    // double returns 5 (since method append_no_dups_or_spikes)
-    /***
-      TODO it now returns sometimes 4, sometimes 5 for double. Depending on clockwise/closed too. Fix this.
-    test_one<Polygon, Polygon, Polygon>("ggl_list_20110306_javier",
-        ggl_list_20110306_javier[0], ggl_list_20110306_javier[1],
-        1, if_typed_tt<ct>(5, 4), 
-        0.6649875, 
-        if_typed<ct, float>(1.0, 0.01)); 
-    ***/
+    if (! ccw && open)
+    {
+        // Pointcount for ttmath/double (both 5) or float (4)
+        // double returns 5 (since method append_no_dups_or_spikes)
+        // but not for ccw/open. Those cases has to be adapted once, anyway, 
+        // because for open always one point too much is generated...
+        test_one<Polygon, Polygon, Polygon>("ggl_list_20110306_javier",
+            ggl_list_20110306_javier[0], ggl_list_20110306_javier[1],
+            1, if_typed<ct, float>(4, 5), 
+            0.6649875, 
+            if_typed<ct, float>(1.0, 0.01)); 
+    }
         
     test_one<Polygon, Polygon, Polygon>("ggl_list_20110307_javier",
         ggl_list_20110307_javier[0], ggl_list_20110307_javier[1],
Modified: trunk/libs/geometry/test/algorithms/test_difference.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_difference.hpp	Mon Aug 26 17:02:18 2013	(r85479)
+++ trunk/libs/geometry/test/algorithms/test_difference.hpp	2013-08-26 17:15:47 EDT (Mon, 26 Aug 2013)	(r85480)
@@ -144,7 +144,7 @@
                 "difference: " << caseid
                 << " #points expected: " << expected_point_count
                 << " detected: " << n
-                << " type: " << string_from_type<coordinate_type>::name()
+                << " type: " << (type_for_assert_message<G1, G2>())
                 );
     }
 
@@ -154,7 +154,7 @@
                 "difference: " << caseid
                 << " #outputs expected: " << expected_count
                 << " detected: " << clip.size()
-                << " type: " << string_from_type<coordinate_type>::name()
+                << " type: " << (type_for_assert_message<G1, G2>())
                 );
     }
 
Modified: trunk/libs/geometry/test/algorithms/test_intersection.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_intersection.hpp	Mon Aug 26 17:02:18 2013	(r85479)
+++ trunk/libs/geometry/test/algorithms/test_intersection.hpp	2013-08-26 17:15:47 EDT (Mon, 26 Aug 2013)	(r85480)
@@ -42,7 +42,7 @@
         double percentage = 0.0001,
         bool debug = false)
 {
-    static const bool is_line = bg::geometry_id<OutputType>::type::value == 2;
+    bool const is_line = bg::geometry_id<OutputType>::type::value == 2;
 
     if (debug)
     {
@@ -102,7 +102,7 @@
                 "intersection: " << caseid
                 << " #points expected: " << expected_point_count
                 << " detected: " << n
-                << " type: " << string_from_type<coordinate_type>::name()
+                << " type: " << (type_for_assert_message<G1, G2>())
                 );
     }
 
@@ -112,7 +112,7 @@
                 "intersection: " << caseid
                 << " #outputs expected: " << expected_count
                 << " detected: " << clip.size()
-                << " type: " << string_from_type<coordinate_type>::name()
+                << " type: " << (type_for_assert_message<G1, G2>())
                 );
     }
 
Modified: trunk/libs/geometry/test/algorithms/test_union.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_union.hpp	Mon Aug 26 17:02:18 2013	(r85479)
+++ trunk/libs/geometry/test/algorithms/test_union.hpp	2013-08-26 17:15:47 EDT (Mon, 26 Aug 2013)	(r85480)
@@ -96,7 +96,7 @@
                 "union: " << caseid
                 << " #points expected: " << expected_point_count
                 << " detected: " << n
-                << " type: " << string_from_type<coordinate_type>::name()
+                << " type: " << (type_for_assert_message<G1, G2>())
                 );
     }
 
Modified: trunk/libs/geometry/test/geometry_test_common.hpp
==============================================================================
--- trunk/libs/geometry/test/geometry_test_common.hpp	Mon Aug 26 17:02:18 2013	(r85479)
+++ trunk/libs/geometry/test/geometry_test_common.hpp	2013-08-26 17:15:47 EDT (Mon, 26 Aug 2013)	(r85480)
@@ -38,7 +38,7 @@
 // Include some always-included-for-testing files
 #if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST)
 
-// Until Boost fixes it, silence warning issued by clang:
+// Until Boost.Test fixes it, silence warning issued by clang:
 // warning: unused variable 'check_is_close' [-Wunused-variable]
 #ifdef __clang__
 # pragma clang diagnostic push
@@ -73,6 +73,15 @@
 #  include <boost/numeric_adaptor/cln_value_type.hpp>
 #endif
 
+// For all tests:
+// - do NOT use "using namespace boost::geometry" to make clear what is Boost.Geometry
+// - use bg:: as short alias
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/point_order.hpp>
+#include <boost/geometry/core/tag.hpp>
+namespace bg = boost::geometry;
+
 
 template <typename T>
 struct string_from_type {};
@@ -130,8 +139,22 @@
     return boost::is_same<CoordinateType, Specified>::value ? value_typed : value;
 }
 
-
-
+template <typename Geometry1, typename Geometry2>
+inline std::string type_for_assert_message()
+{
+    bool const ccw =
+        bg::point_order<Geometry1>::value == bg::counterclockwise
+        || bg::point_order<Geometry2>::value == bg::counterclockwise;
+    bool const open =
+        bg::closure<Geometry1>::value == bg::open
+        || bg::closure<Geometry2>::value == bg::open;
+
+    std::ostringstream out;
+    out << string_from_type<typename bg::coordinate_type<Geometry1>::type>::name()
+        << (ccw ? " ccw" : "")
+        << (open ? " open" : "");
+    return out.str();
+}
 
 struct geographic_policy
 {
@@ -154,12 +177,4 @@
 
 
 
-
-// For all tests:
-// - do NOT use "using namespace boost::geometry" to make clear what is Boost.Geometry
-// - use bg:: as short alias
-#include <boost/geometry/core/tag.hpp>
-namespace bg = boost::geometry;
-
-
 #endif // GEOMETRY_TEST_GEOMETRY_TEST_COMMON_HPP