Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72875 - trunk/libs/geometry/test/algorithms
From: barend.gehrels_at_[hidden]
Date: 2011-07-03 10:21:53


Author: barendgehrels
Date: 2011-07-03 10:21:52 EDT (Sun, 03 Jul 2011)
New Revision: 72875
URL: http://svn.boost.org/trac/boost/changeset/72875

Log:
Added tests for within_code
Text files modified:
   trunk/libs/geometry/test/algorithms/test_within.hpp | 19 +++++++++++++++++++
   trunk/libs/geometry/test/algorithms/within.cpp | 13 +++++++++++++
   2 files changed, 32 insertions(+), 0 deletions(-)

Modified: trunk/libs/geometry/test/algorithms/test_within.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_within.hpp (original)
+++ trunk/libs/geometry/test/algorithms/test_within.hpp 2011-07-03 10:21:52 EDT (Sun, 03 Jul 2011)
@@ -41,6 +41,25 @@
         << " detected: " << detected);
 }
 
+template <typename Geometry1, typename Geometry2>
+void test_within_code(std::string const& wkt1,
+ std::string const& wkt2, int expected)
+{
+ Geometry1 geometry1;
+ Geometry2 geometry2;
+
+ bg::read_wkt(wkt1, geometry1);
+ bg::read_wkt(wkt2, geometry2);
+
+ int detected = bg::detail::within_code(geometry1, geometry2);
+
+ BOOST_CHECK_MESSAGE(detected == expected,
+ "within_code: " << wkt1
+ << " in " << wkt2
+ << " -> Expected: " << expected
+ << " detected: " << detected);
+}
+
 
 template <typename Point, bool Clockwise, bool Closed>
 void test_ordered_ring(std::string const& wkt_point,

Modified: trunk/libs/geometry/test/algorithms/within.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/within.cpp (original)
+++ trunk/libs/geometry/test/algorithms/within.cpp 2011-07-03 10:21:52 EDT (Sun, 03 Jul 2011)
@@ -41,6 +41,19 @@
     test_geometry<box_type, box_type>("BOX(1 1,2 2)", "BOX(0 0,3 3)", true);
     test_geometry<box_type, box_type>("BOX(0 0,3 3)", "BOX(1 1,2 2)", false);
 
+ test_within_code<P, box_type>("POINT(1 1)", "BOX(0 0,2 2)", 1);
+ test_within_code<P, box_type>("POINT(1 0)", "BOX(0 0,2 2)", 0);
+ test_within_code<P, box_type>("POINT(0 1)", "BOX(0 0,2 2)", 0);
+ test_within_code<P, box_type>("POINT(0 3)", "BOX(0 0,2 2)", -1);
+ test_within_code<P, box_type>("POINT(3 3)", "BOX(0 0,2 2)", -1);
+
+ test_within_code<box_type, box_type>("BOX(1 1,2 2)", "BOX(0 0,3 3)", 1);
+ test_within_code<box_type, box_type>("BOX(0 1,2 2)", "BOX(0 0,3 3)", 0);
+ test_within_code<box_type, box_type>("BOX(1 0,2 2)", "BOX(0 0,3 3)", 0);
+ test_within_code<box_type, box_type>("BOX(1 1,2 3)", "BOX(0 0,3 3)", 0);
+ test_within_code<box_type, box_type>("BOX(1 1,3 2)", "BOX(0 0,3 3)", 0);
+ test_within_code<box_type, box_type>("BOX(1 1,3 4)", "BOX(0 0,3 3)", -1);
+
 
     // Mixed point types
     test_geometry


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