Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56933 - in sandbox/ggl/formal_review_request/libs/ggl/test: . arithmetic core iterators test_common
From: barend.gehrels_at_[hidden]
Date: 2009-10-16 15:59:41


Author: barendgehrels
Date: 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
New Revision: 56933
URL: http://svn.boost.org/trac/boost/changeset/56933

Log:
Merged assign_box_corner with assign
Added assign_point_to_box (also in assign)
Updated some headerfiles, too much or missing
Added non-const version of point_const_iterator and renamed to vertex_iterator
Removed wrong assertions in segment_iterator

Added testsuitea for arithmetic/iterators/util
Added:
   sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/
   sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/arithmetic.cpp (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/dot_product.cpp (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/test/ggl_test_common.hpp (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/test/iterators/
   sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/test/iterators/circular_iterator.cpp (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/test/iterators/ever_circling_iterator.cpp (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/test/iterators/segment_iterator.cpp (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/test/iterators/vertex_iterator.cpp (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/test/test_common/
   sandbox/ggl/formal_review_request/libs/ggl/test/test_common/test_point.hpp (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/test/test_common/with_pointer.hpp (contents, props changed)
Text files modified:
   sandbox/ggl/formal_review_request/libs/ggl/test/core/access.cpp | 5 +++--
   sandbox/ggl/formal_review_request/libs/ggl/test/core/coordinate_dimension.cpp | 5 +++--
   sandbox/ggl/formal_review_request/libs/ggl/test/core/coordinate_system.cpp | 5 +++--
   sandbox/ggl/formal_review_request/libs/ggl/test/core/coordinate_type.cpp | 5 +++--
   sandbox/ggl/formal_review_request/libs/ggl/test/core/geometry_id.cpp | 5 +++--
   sandbox/ggl/formal_review_request/libs/ggl/test/core/point_type.cpp | 4 ++--
   sandbox/ggl/formal_review_request/libs/ggl/test/core/radian_access.cpp | 5 ++---
   sandbox/ggl/formal_review_request/libs/ggl/test/core/reverse_dispatch.cpp | 3 +--
   sandbox/ggl/formal_review_request/libs/ggl/test/core/ring.cpp | 4 ++--
   sandbox/ggl/formal_review_request/libs/ggl/test/core/tag.cpp | 4 ++--
   sandbox/ggl/formal_review_request/libs/ggl/test/core/topological_dimension.cpp | 4 ++--
   11 files changed, 26 insertions(+), 23 deletions(-)

Added: sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,10 @@
+# Generic Geometry Library unit tests
+#
+# Copyright Bruno Lalande 2008
+# Copyright Barend Gehrels, Geodan Holding B.V. Amsterdam, the Netherlands.
+# Use, modification and distribution is subject to the Boost Software License,
+# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+run arithmetic.cpp ;
+run dot_product.cpp ;

Added: sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/arithmetic.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/arithmetic.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,119 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#include <ggl_test_common.hpp>
+
+
+#include <ggl/arithmetic/arithmetic.hpp>
+
+#include <ggl/algorithms/assign.hpp>
+
+#include <ggl/geometries/point.hpp>
+#include <ggl/geometries/adapted/c_array_cartesian.hpp>
+#include <ggl/geometries/adapted/tuple_cartesian.hpp>
+#include <test_common/test_point.hpp>
+
+
+using namespace ggl;
+
+template <typename P>
+void test_addition()
+{
+ P p1;
+ ggl::assign(p1, 1, 2, 3);
+ ggl::add_value(p1, 10);
+ BOOST_CHECK(get<0>(p1) == 11);
+ BOOST_CHECK(get<1>(p1) == 12);
+ BOOST_CHECK(get<2>(p1) == 13);
+
+ P p2;
+ ggl::assign(p2, 4, 5, 6);
+ ggl::add_point(p1, p2);
+ BOOST_CHECK(get<0>(p1) == 15);
+ BOOST_CHECK(get<1>(p1) == 17);
+ BOOST_CHECK(get<2>(p1) == 19);
+}
+
+template <typename P>
+void test_subtraction()
+{
+ P p1;
+ ggl::assign(p1, 1, 2, 3);
+ ggl::subtract_value(p1, 10);
+ BOOST_CHECK(get<0>(p1) == -9);
+ BOOST_CHECK(get<1>(p1) == -8);
+ BOOST_CHECK(get<2>(p1) == -7);
+
+ P p2;
+ ggl::assign(p2, 4, 6, 8);
+ ggl::subtract_point(p1, p2);
+ BOOST_CHECK(get<0>(p1) == -13);
+ BOOST_CHECK(get<1>(p1) == -14);
+ BOOST_CHECK(get<2>(p1) == -15);
+}
+
+template <typename P>
+void test_multiplication()
+{
+ P p1;
+ ggl::assign(p1, 1, 2, 3);
+ ggl::multiply_value(p1, 5);
+ BOOST_CHECK(get<0>(p1) == 5);
+ BOOST_CHECK(get<1>(p1) == 10);
+ BOOST_CHECK(get<2>(p1) == 15);
+
+ P p2;
+ ggl::assign(p2, 4, 5, 6);
+ ggl::multiply_point(p1, p2);
+ BOOST_CHECK(get<0>(p1) == 20);
+ BOOST_CHECK(get<1>(p1) == 50);
+ BOOST_CHECK(get<2>(p1) == 90);
+}
+
+template <typename P>
+void test_division()
+{
+ P p1;
+ ggl::assign(p1, 50, 100, 150);
+ ggl::divide_value(p1, 5);
+ BOOST_CHECK(get<0>(p1) == 10);
+ BOOST_CHECK(get<1>(p1) == 20);
+ BOOST_CHECK(get<2>(p1) == 30);
+
+ P p2;
+ ggl::assign(p2, 2, 4, 6);
+ ggl::divide_point(p1, p2);
+ BOOST_CHECK(get<0>(p1) == 5);
+ BOOST_CHECK(get<1>(p1) == 5);
+ BOOST_CHECK(get<2>(p1) == 5);
+}
+
+
+template <typename P>
+void test_all()
+{
+ test_addition<P>();
+ test_subtraction<P>();
+ test_multiplication<P>();
+ test_division<P>();
+}
+
+
+int test_main(int, char* [])
+{
+ test_all<int[3]>();
+ test_all<float[3]>();
+ test_all<double[3]>();
+ test_all<test::test_point>();
+ test_all<point<int, 3, ggl::cs::cartesian> >();
+ test_all<point<float, 3, ggl::cs::cartesian> >();
+ test_all<point<double, 3, ggl::cs::cartesian> >();
+
+ return 0;
+}

Added: sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/dot_product.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/dot_product.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,46 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#include <ggl_test_common.hpp>
+
+#include <ggl/arithmetic/dot_product.hpp>
+
+
+#include <ggl/algorithms/assign.hpp>
+
+#include <ggl/geometries/point.hpp>
+#include <ggl/geometries/adapted/c_array_cartesian.hpp>
+#include <ggl/geometries/adapted/tuple_cartesian.hpp>
+#include <test_common/test_point.hpp>
+
+
+using namespace ggl;
+
+template <typename P>
+void test_all()
+{
+ P p1;
+ ggl::assign(p1, 1, 2, 3);
+ P p2;
+ ggl::assign(p2, 4, 5, 6);
+ BOOST_CHECK(ggl::dot_product(p1, p2) == 1*4 + 2*5 + 3*6);
+}
+
+int test_main(int, char* [])
+{
+ test_all<int[3]>();
+ test_all<float[3]>();
+ test_all<double[3]>();
+ test_all<test::test_point>();
+ test_all<point<int, 3, ggl::cs::cartesian> >();
+ test_all<point<float, 3, ggl::cs::cartesian> >();
+ test_all<point<double, 3, ggl::cs::cartesian> >();
+
+ return 0;
+}

Modified: sandbox/ggl/formal_review_request/libs/ggl/test/core/access.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/access.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/access.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -6,8 +6,9 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/test/floating_point_comparison.hpp>
-#include <boost/test/included/test_exec_monitor.hpp>
+
+#include <ggl_test_common.hpp>
+
 
 #include <ggl/core/access.hpp>
 

Modified: sandbox/ggl/formal_review_request/libs/ggl/test/core/coordinate_dimension.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/coordinate_dimension.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/coordinate_dimension.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -5,8 +5,9 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/concept/assert.hpp>
-#include <boost/test/included/test_exec_monitor.hpp>
+
+#include <ggl_test_common.hpp>
+
 
 #include <ggl/core/coordinate_dimension.hpp>
 

Modified: sandbox/ggl/formal_review_request/libs/ggl/test/core/coordinate_system.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/coordinate_system.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/coordinate_system.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -5,8 +5,9 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/concept/assert.hpp>
-#include <boost/test/included/test_exec_monitor.hpp>
+
+#include <ggl_test_common.hpp>
+
 
 #include <ggl/core/coordinate_system.hpp>
 

Modified: sandbox/ggl/formal_review_request/libs/ggl/test/core/coordinate_type.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/coordinate_type.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/coordinate_type.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -5,8 +5,9 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/concept/assert.hpp>
-#include <boost/test/included/test_exec_monitor.hpp>
+
+#include <ggl_test_common.hpp>
+
 
 #include <ggl/core/coordinate_type.hpp>
 

Modified: sandbox/ggl/formal_review_request/libs/ggl/test/core/geometry_id.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/geometry_id.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/geometry_id.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -5,8 +5,9 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/concept/assert.hpp>
-#include <boost/test/included/test_exec_monitor.hpp>
+
+#include <ggl_test_common.hpp>
+
 
 #include <ggl/core/geometry_id.hpp>
 

Modified: sandbox/ggl/formal_review_request/libs/ggl/test/core/point_type.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/point_type.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/point_type.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -5,8 +5,8 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/concept/assert.hpp>
-#include <boost/test/included/test_exec_monitor.hpp>
+
+#include <ggl_test_common.hpp>
 
 
 #include <ggl/core/tag.hpp>

Modified: sandbox/ggl/formal_review_request/libs/ggl/test/core/radian_access.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/radian_access.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/radian_access.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -6,14 +6,13 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/test/floating_point_comparison.hpp>
-#include <boost/test/included/test_exec_monitor.hpp>
 
+#include <ggl_test_common.hpp>
 
-#include <ggl/core/coordinate_type.hpp>
 #include <ggl/core/radian_access.hpp>
 
 #include <ggl/core/cs.hpp>
+#include <ggl/core/coordinate_type.hpp>
 #include <ggl/geometries/point.hpp>
 
 

Modified: sandbox/ggl/formal_review_request/libs/ggl/test/core/reverse_dispatch.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/reverse_dispatch.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/reverse_dispatch.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -6,9 +6,8 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <iostream>
 
-#include <boost/test/included/test_exec_monitor.hpp>
+#include <ggl_test_common.hpp>
 
 #include <ggl/core/reverse_dispatch.hpp>
 

Modified: sandbox/ggl/formal_review_request/libs/ggl/test/core/ring.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/ring.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/ring.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -6,9 +6,9 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <iostream>
 
-#include <boost/test/included/test_exec_monitor.hpp>
+#include <ggl_test_common.hpp>
+
 
 // To be tested:
 #include <ggl/core/ring_type.hpp>

Modified: sandbox/ggl/formal_review_request/libs/ggl/test/core/tag.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/tag.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/tag.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -5,8 +5,8 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/concept/assert.hpp>
-#include <boost/test/included/test_exec_monitor.hpp>
+
+#include <ggl_test_common.hpp>
 
 #include <ggl/core/tag.hpp>
 

Modified: sandbox/ggl/formal_review_request/libs/ggl/test/core/topological_dimension.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/topological_dimension.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/topological_dimension.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -5,8 +5,8 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/concept/assert.hpp>
-#include <boost/test/included/test_exec_monitor.hpp>
+
+#include <ggl_test_common.hpp>
 
 #include <ggl/core/topological_dimension.hpp>
 

Added: sandbox/ggl/formal_review_request/libs/ggl/test/ggl_test_common.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/ggl_test_common.hpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,31 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef GGL_TEST_GGL_TEST_COMMON_HPP
+#define GGL_TEST_GGL_TEST_COMMON_HPP
+
+// Just include some always-included files
+
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/test/included/test_exec_monitor.hpp>
+
+
+#if defined(HAVE_GMP)
+# include <boost/numeric_adaptor/gmp_value_type.hpp>
+#endif
+#if defined(HAVE_CLN)
+# include <boost/numeric_adaptor/cln_value_type.hpp>
+#endif
+
+#if defined(HAVE_CLN) || defined(HAVE_GMP)
+# include <boost/numeric_adaptor/numeric_adaptor.hpp>
+#endif
+
+
+#endif // GGL_TEST_GGL_TEST_COMMON_HPP

Added: sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,12 @@
+# Generic Geometry Library unit tests
+#
+# Copyright Bruno Lalande 2008
+# Copyright Barend Gehrels, Geodan Holding B.V. Amsterdam, the Netherlands.
+# Use, modification and distribution is subject to the Boost Software License,
+# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+run circular_iterator.cpp ;
+run ever_circling_iterator.cpp ;
+run vertex_iterator.cpp ;
+run segment_iterator.cpp ;

Added: sandbox/ggl/formal_review_request/libs/ggl/test/iterators/circular_iterator.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/iterators/circular_iterator.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,101 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <algorithm>
+#include <iterator>
+#include <sstream>
+#include <string>
+
+#include <ggl_test_common.hpp>
+
+#include <ggl/iterators/circular_iterator.hpp>
+
+#include <ggl/core/coordinate_type.hpp>
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+#include <ggl/geometries/cartesian2d.hpp>
+
+template <typename G>
+void test_geometry(const std::string& wkt)
+{
+ G geo;
+ ggl::read_wkt(wkt, geo);
+ typedef typename boost::range_const_iterator<G>::type normal_iterator;
+ typedef ggl::circular_iterator<normal_iterator> circular_iterator;
+
+ circular_iterator end(boost::end(geo));
+
+ {
+ // 1: normal start position
+ normal_iterator start = boost::begin(geo);
+
+ std::ostringstream out;
+ for (circular_iterator it(boost::begin(geo), boost::end(geo), start);
+ it != end; ++it)
+ {
+ out << ggl::get<0>(*it);
+ }
+ BOOST_CHECK_EQUAL(out.str(), "12345");
+ }
+
+ {
+ // 2: start somewhere in the middle
+ normal_iterator start = boost::begin(geo) + 2;
+
+ std::ostringstream out;
+ for (circular_iterator it(boost::begin(geo), boost::end(geo), start);
+ it != end; ++it)
+ {
+ out << ggl::get<0>(*it);
+ }
+ BOOST_CHECK_EQUAL(out.str(), "34512");
+ }
+
+ {
+ // 3: start at end position
+ normal_iterator start = boost::begin(geo) + boost::size(geo) - 1;
+
+ std::ostringstream out;
+ for (circular_iterator it(boost::begin(geo), boost::end(geo), start);
+ it != end; ++it)
+ {
+ out << ggl::get<0>(*it);
+ }
+ BOOST_CHECK_EQUAL(out.str(), "51234");
+ }
+
+ {
+ // 4: check copy behaviour
+ G copy;
+
+ {
+ normal_iterator start = boost::begin(geo) + 2;
+ circular_iterator it(boost::begin(geo), boost::end(geo), start);
+ std::copy<circular_iterator>(it, end, std::back_inserter(copy));
+ }
+
+ std::ostringstream out;
+ for (normal_iterator cit = boost::begin(copy); cit != boost::end(copy); ++cit)
+ {
+ out << ggl::get<0>(*cit);
+ }
+ BOOST_CHECK_EQUAL(out.str(), "34512");
+ }
+}
+
+template <typename P>
+void test_all()
+{
+ test_geometry<ggl::linestring<P> >("linestring(1 1,2 2,3 3,4 4,5 5)");
+}
+
+int test_main(int, char* [])
+{
+ test_all<ggl::point_2d>();
+
+ return 0;
+}

Added: sandbox/ggl/formal_review_request/libs/ggl/test/iterators/ever_circling_iterator.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/iterators/ever_circling_iterator.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,80 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <sstream>
+#include <string>
+
+#include <ggl_test_common.hpp>
+
+#include <ggl/iterators/ever_circling_iterator.hpp>
+
+#include <ggl/core/coordinate_type.hpp>
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+#include <ggl/geometries/cartesian2d.hpp>
+
+template <typename G>
+void test_geometry(const std::string& wkt)
+{
+ G geo;
+ ggl::read_wkt(wkt, geo);
+ typedef typename boost::range_const_iterator<G>::type iterator_type;
+
+
+ // Run 3 times through the geometry
+ int n = boost::size(geo) * 3;
+
+ {
+ std::ostringstream out;
+ ggl::ever_circling_iterator<iterator_type> it(boost::begin(geo), boost::end(geo));
+ for (int i = 0; i < n; ++i, ++it)
+ {
+ out << ggl::get<0>(*it);
+ }
+ BOOST_CHECK_EQUAL(out.str(), "123451234512345");
+ }
+
+ {
+ std::ostringstream out;
+ // Start somewhere
+ ggl::ever_circling_iterator<iterator_type> it(
+ boost::begin(geo), boost::end(geo), boost::begin(geo) + 1);
+ for (int i = 0; i < n; ++i, ++it)
+ {
+ out << ggl::get<0>(*it);
+ }
+ BOOST_CHECK_EQUAL(out.str(), "234512345123451");
+ }
+
+ {
+ std::ostringstream out;
+
+ // Navigate to somewhere
+ ggl::ever_circling_iterator<iterator_type> it(boost::begin(geo), boost::end(geo));
+ for (int i = 0; i < n; ++i, ++it)
+ {
+ const int m = boost::size(geo);
+ it.moveto(boost::begin(geo) + m - (i % m) - 1);
+ out << ggl::get<0>(*it);
+ }
+ BOOST_CHECK_EQUAL(out.str(), "543215432154321");
+ }
+
+}
+
+template <typename P>
+void test_all()
+{
+ test_geometry<ggl::linestring<P> >("linestring(1 1,2 2,3 3,4 4,5 5)");
+}
+
+int test_main(int, char* [])
+{
+ test_all<ggl::point_2d>();
+
+ return 0;
+}

Added: sandbox/ggl/formal_review_request/libs/ggl/test/iterators/segment_iterator.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/iterators/segment_iterator.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,79 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// Copyright Mateusz Loskot 2009, mateusz_at_[hidden]
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <algorithm>
+#include <list>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include <ggl_test_common.hpp>
+
+#include <ggl/iterators/segment_iterator.hpp>
+
+
+#include <ggl/core/coordinate_type.hpp>
+#include <ggl/geometries/cartesian2d.hpp>
+#include <ggl/geometries/point.hpp>
+#include <ggl/geometries/segment.hpp>
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+
+template <typename C>
+void test_linestring(const std::string& wkt, const std::string& expected)
+{
+ typedef C point_list;
+ typedef typename C::value_type point;
+ typedef typename C::iterator base_iterator;
+ typedef ggl::segment_iterator<base_iterator, point> segment_iterator;
+ typedef typename segment_iterator::value_type segment;
+ typedef ggl::linestring<point> linestring;
+
+ linestring g;
+ ggl::read_wkt(wkt, g);
+
+ point_list v;
+ std::copy(g.begin(), g.end(), std::back_insert_iterator<point_list>(v));
+ BOOST_CHECK_EQUAL(g.size(), v.size());
+
+ segment_iterator it(v.begin(), v.end());
+ segment_iterator end(v.end());
+
+ std::ostringstream oss;
+ while (it != end)
+ {
+ segment const& s = *it;
+ oss << ggl::get<0>(s.first) << ggl::get<1>(s.first)
+ << ggl::get<0>(s.second) << ggl::get<1>(s.second);
+ ++it;
+ }
+ BOOST_CHECK_EQUAL(oss.str(), expected);
+}
+
+int test_main(int, char* [])
+{
+ // Test std::vector
+ typedef std::vector<ggl::point_2d> points_v;
+ test_linestring<points_v>("linestring empty", "");
+ test_linestring<points_v>("linestring ()", "");
+ test_linestring<points_v>("linestring (1 1)", "");
+ test_linestring<points_v>("linestring (1 1, 2 2, 3 3)", "11222233");
+ test_linestring<points_v>("linestring (1 1, 2 2, 3 3, 4 4)", "112222333344");
+ test_linestring<points_v>("linestring (1 1, 2 2, 3 3, 4 4, 5 5, 6 6)", "11222233334444555566");
+
+ // Test std::list
+ typedef std::list<ggl::point_2d> points_l;
+ test_linestring<points_l>("linestring empty", "");
+ test_linestring<points_l>("linestring ()", "");
+ test_linestring<points_l>("linestring (1 1)", "");
+ test_linestring<points_l>("linestring (1 1, 2 2, 3 3)", "11222233");
+ test_linestring<points_l>("linestring (1 1, 2 2, 3 3, 4 4)", "112222333344");
+ test_linestring<points_l>("linestring (1 1, 2 2, 3 3, 4 4, 5 5, 6 6)", "11222233334444555566");
+
+ return 0;
+}

Added: sandbox/ggl/formal_review_request/libs/ggl/test/iterators/vertex_iterator.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/iterators/vertex_iterator.cpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,60 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <deque>
+
+#include <ggl_test_common.hpp>
+
+#include <ggl/iterators/vertex_iterator.hpp>
+
+#include <ggl/core/cs.hpp>
+#include <ggl/geometries/point.hpp>
+#include <ggl/geometries/linestring.hpp>
+#include <ggl/geometries/linear_ring.hpp>
+#include <ggl/geometries/polygon.hpp>
+
+template <typename G, bool IsConst, typename Expected>
+void test_geometry()
+{
+ typedef typename ggl::vertex_iterator<G, IsConst>::type it;
+ BOOST_CHECK_EQUAL(typeid(it).name(), typeid(Expected).name());
+}
+
+template <typename P>
+void test_all()
+{
+ test_geometry<ggl::linestring<P>, true,
+ typename std::vector<P>::const_iterator>();
+ test_geometry<ggl::linestring<P, std::deque>, true,
+ typename std::deque<P>::const_iterator>();
+
+ test_geometry<ggl::linestring<P>, false,
+ typename std::vector<P>::iterator>();
+
+ test_geometry<ggl::linear_ring<P>, true,
+ typename std::vector<P>::const_iterator>();
+ test_geometry<std::vector<P>, true,
+ typename std::vector<P>::const_iterator>();
+
+ // So by nature of point_const_iterator, even a polygon should
+ // deliver a the iterator of the rings making it up
+ test_geometry<ggl::polygon<P>, true,
+ typename std::vector<P>::const_iterator>();
+ test_geometry<ggl::polygon<P, std::deque>, true,
+ typename std::deque<P>::const_iterator>();
+ test_geometry<ggl::polygon<P, std::deque, std::deque>, true,
+ typename std::deque<P>::const_iterator>();
+ test_geometry<ggl::polygon<P, std::deque, std::deque>, false,
+ typename std::deque<P>::iterator>();
+}
+
+int test_main(int, char* [])
+{
+ test_all<ggl::point<double, 2, ggl::cs::cartesian> >();
+
+ return 0;
+}

Added: sandbox/ggl/formal_review_request/libs/ggl/test/test_common/test_point.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/test_common/test_point.hpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,92 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef GGL_TEST_TEST_COMMON_TEST_POINT_HPP
+#define GGL_TEST_TEST_COMMON_TEST_POINT_HPP
+
+#include <ggl/core/access.hpp>
+#include <ggl/core/coordinate_type.hpp>
+#include <ggl/core/coordinate_system.hpp>
+#include <ggl/core/coordinate_dimension.hpp>
+#include <ggl/core/cs.hpp>
+#include <ggl/core/tag.hpp>
+
+
+namespace test
+{
+
+// Test point class
+
+struct test_point
+{
+ float c1, c2, c3;
+};
+
+
+// Struct set of metafunctions to read/write coordinates above, specialized per dimension
+template<int I>
+struct accessor {};
+
+template<>
+struct accessor<0>
+{
+ static inline const float& get(const test_point& p) { return p.c1; }
+ static inline void set(test_point& p, const float& value) { p.c1 = value; }
+};
+
+template<>
+struct accessor<1>
+{
+ static inline const float& get(const test_point& p) { return p.c2; }
+ static inline void set(test_point& p, const float& value) { p.c2 = value; }
+};
+
+template<>
+struct accessor<2>
+{
+ static inline const float& get(const test_point& p) { return p.c3; }
+ static inline void set(test_point& p, const float& value) { p.c3 = value; }
+};
+
+
+} // namespace test
+
+
+namespace ggl { namespace traits {
+
+template<>
+struct tag<test::test_point> { typedef point_tag type; };
+
+template<>
+struct coordinate_type<test::test_point> { typedef float type; };
+
+template<>
+struct coordinate_system<test::test_point> { typedef cs::cartesian type; };
+
+template<>
+struct dimension<test::test_point>: boost::mpl::int_<3> {};
+
+template<> struct access<test::test_point>
+{
+ template <int I>
+ static inline const float& get(const test::test_point& p)
+ {
+ return test::accessor<I>::get(p);
+ }
+
+ template <int I>
+ static inline void set(test::test_point& p, const float& value)
+ {
+ test::accessor<I>::set(p, value);
+ }
+};
+
+}} // namespace ggl::traits
+
+#endif // GGL_TEST_TEST_COMMON_TEST_POINT_HPP

Added: sandbox/ggl/formal_review_request/libs/ggl/test/test_common/with_pointer.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/test_common/with_pointer.hpp 2009-10-16 15:59:36 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,70 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef GGL_TEST_COMMON_WITH_POINTER_HPP
+#define GGL_TEST_COMMON_WITH_POINTER_HPP
+
+
+#include <ggl/core/access.hpp>
+#include <ggl/core/coordinate_type.hpp>
+#include <ggl/core/coordinate_system.hpp>
+#include <ggl/core/coordinate_dimension.hpp>
+#include <ggl/core/cs.hpp>
+#include <ggl/core/tag.hpp>
+
+
+namespace test
+{
+
+// Sample point, having x/y
+struct test_point_xy
+{
+ float x,y;
+};
+
+}
+
+
+namespace ggl { namespace traits {
+
+template<> struct tag<test::test_point_xy*>
+{ typedef point_tag type; };
+
+template<> struct coordinate_type<test::test_point_xy*>
+{ typedef double type; };
+
+template<> struct coordinate_system<test::test_point_xy*>
+{ typedef cs::cartesian type; };
+
+template<> struct dimension<test::test_point_xy*> : boost::mpl::int_<2> {};
+
+template<>
+struct access<test::test_point_xy*>
+{
+ template <std::size_t I>
+ static double get(const test::test_point_xy* p)
+ {
+ return I == 0 ? p->x : p->y;
+ // Or implement an accessor with specializations
+ }
+
+ template <int I>
+ static void set(test::test_point_xy* p, const double& value)
+ {
+ // Or (better) implement an accessor with specializations
+ if (I == 0) p->x = value;
+ else if (I == 1) p->y = value;
+ }
+
+};
+
+}} // namespace ggl::traits
+
+
+#endif // #ifndef GGL_TEST_COMMON_WITH_POINTER_HPP


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