$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r82032 - in sandbox-branches/geometry/index: boost/geometry/extensions/index test
From: adam.wulkiewicz_at_[hidden]
Date: 2012-12-16 14:34:52
Author: awulkiew
Date: 2012-12-16 14:34:51 EST (Sun, 16 Dec 2012)
New Revision: 82032
URL: http://svn.boost.org/trac/boost/changeset/82032
Log:
Iterators check changed in erase(f, l).
Tests upgraded.
Text files modified: 
   sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp |    20 +++++++++------                         
   sandbox-branches/geometry/index/test/static_vector.cpp                            |    50 +++++++++++++++++---------------------- 
   2 files changed, 34 insertions(+), 36 deletions(-)
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp	(original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp	2012-12-16 14:34:51 EST (Sun, 16 Dec 2012)
@@ -257,8 +257,8 @@
     // basic
     void erase(iterator first, iterator last)
     {
-        check_iterator_end_neq(first);
-        check_iterator_end_neq(last);
+        check_iterator_end_eq(first);
+        check_iterator_end_eq(last);
         
         difference_type n = std::distance(first, last);
         BOOST_ASSERT_MSG(0 <= n, "invalid range");
@@ -754,9 +754,11 @@
         BOOST_ASSERT_MSG(0 < m_size, "the container is empty");
     }
 
-    void check_iterator_end_neq(iterator position)
+    void check_iterator_end_neq(const_iterator position)
     {
-        BOOST_GEOMETRY_INDEX_ASSERT_UNUSED_PARAM(
+        BOOST_ASSERT_MSG(this->begin() <= position && position < this->end(), "iterator out of bounds");
+
+        /*BOOST_GEOMETRY_INDEX_ASSERT_UNUSED_PARAM(
             difference_type dist = std::distance(this->begin(), position);
         )
         BOOST_ASSERT_MSG(
@@ -765,12 +767,14 @@
                 (static_cast<size_type>(dist) < m_size) :
                 ( dist < static_cast<difference_type>(m_size))
             ), "invalid iterator"
-        );
+        );*/
     }
 
-    void check_iterator_end_eq(iterator position)
+    void check_iterator_end_eq(const_iterator position)
     {
-        BOOST_GEOMETRY_INDEX_ASSERT_UNUSED_PARAM(
+        BOOST_ASSERT_MSG(this->begin() <= position && position <= this->end(), "iterator out of bounds");
+
+        /*BOOST_GEOMETRY_INDEX_ASSERT_UNUSED_PARAM(
             difference_type dist = std::distance(this->begin(), position);
         )
         BOOST_ASSERT_MSG(
@@ -779,7 +783,7 @@
                 (static_cast<size_type>(dist) <= m_size) :
                 ( dist <= static_cast<difference_type>(m_size))
             ), "invalid iterator"
-        );
+        );*/
     }
 
     Value * ptr()
Modified: sandbox-branches/geometry/index/test/static_vector.cpp
==============================================================================
--- sandbox-branches/geometry/index/test/static_vector.cpp	(original)
+++ sandbox-branches/geometry/index/test/static_vector.cpp	2012-12-16 14:34:51 EST (Sun, 16 Dec 2012)
@@ -307,39 +307,33 @@
     for ( size_t i = 0 ; i < N ; ++i )
         s.push_back(T(i));
 
+    // erase(pos)
     {
-        static_vector<T, N> s1(s);
-
-        for ( size_t i = 1 ; i < N ; ++i )
-        {
-            BOOST_CHECK(s1.front() == T(i-1));
-            s1.erase(s1.begin());
-            BOOST_CHECK(s1.front() == T(i));
-        }
-        BOOST_CHECK(s1.size() == 1);
-    }
-
-    {
-        static_vector<T, N> s1(s);
-
-        for ( size_t i = N ; i > 1 ; --i )
+        for ( size_t i = 0 ; i < N ; ++i )
         {
-            BOOST_CHECK(s1.back() == T(i-1));
-            s1.erase(s1.end() - 1);
-            BOOST_CHECK(s1.back() == T(i-2));
-        }
-        BOOST_CHECK(s1.size() == 1);
+            static_vector<T, N> s1(s);
+            s1.erase(s1.begin() + i);
+            BOOST_CHECK(s1.size() == N - 1);
+            for ( size_t j = 0 ; j < i ; ++j )
+                BOOST_CHECK(s1[j] == T(j));
+            for ( size_t j = i+1 ; j < N ; ++j )
+                BOOST_CHECK(s1[j-1] == T(j));
+        }        
     }
-
+    // erase(first, last)
     {
-        static_vector<T, N> s1(s);
-
-        for ( size_t i = 1 ; i < N - 2 ; i += 3 )
+        size_t n = N/3;
+        for ( size_t i = 0 ; i <= N ; ++i )
         {
-            BOOST_CHECK(s1.front() == T(i-1));
-            s1.erase(s1.begin(), s1.begin() + 3);
-            BOOST_CHECK(s1.front() == T(i+2));
-        }
+            static_vector<T, N> s1(s);
+            size_t removed = i + n < N ? n : N - i;
+            s1.erase(s1.begin() + i, s1.begin() + i + removed);
+            BOOST_CHECK(s1.size() == N - removed);
+            for ( size_t j = 0 ; j < i ; ++j )
+                BOOST_CHECK(s1[j] == T(j));
+            for ( size_t j = i+n ; j < N ; ++j )
+                BOOST_CHECK(s1[j-n] == T(j));
+        }        
     }
 }