Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82002 - in sandbox-branches/geometry/index: boost/geometry/extensions/index test
From: adam.wulkiewicz_at_[hidden]
Date: 2012-12-15 19:58:08


Author: awulkiew
Date: 2012-12-15 19:58:07 EST (Sat, 15 Dec 2012)
New Revision: 82002
URL: http://svn.boost.org/trac/boost/changeset/82002

Log:
Error fixed in static_vector::insert(pos, val).
Test added.
Text files modified:
   sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp | 2 +-
   sandbox-branches/geometry/index/test/static_vector.cpp | 27 +++++++++++++++++++++++++++
   2 files changed, 28 insertions(+), 1 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-15 19:58:07 EST (Sat, 15 Dec 2012)
@@ -181,7 +181,7 @@
         {
             this->uninitialized_fill(this->end(), *(this->end() - 1)); // may throw
             ++m_size; // update end
- this->move_backward(position + 1, this->end() - 2, this->end() - 1); // may throw
+ this->move_backward(position, this->end() - 2, this->end() - 1); // may throw
             this->fill(position, value); // may throw
         }
     }

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-15 19:58:07 EST (Sat, 15 Dec 2012)
@@ -343,6 +343,28 @@
     }
 }
 
+template <typename T, size_t N>
+void test_insert_nd(T const& v)
+{
+ size_t h = N/2;
+
+ static_vector<T, N> s;
+
+ for ( size_t i = 0 ; i < h ; ++i )
+ s.push_back(T(i));
+
+ {
+ static_vector<T, N> s1(s);
+ for ( size_t i = 0 ; i < h ; ++i )
+ s1.insert(s1.begin(), v);
+ BOOST_CHECK(s1.size() == 2*h);
+ for ( size_t i = 0 ; i < h ; ++i )
+ BOOST_CHECK(s1[i] == v);
+ for ( size_t i = 0 ; i < h ; ++i )
+ BOOST_CHECK(s1[i+h] == T(i));
+ }
+}
+
 int test_main(int, char* [])
 {
     BOOST_CHECK(counting_value::count() == 0);
@@ -397,5 +419,10 @@
     test_erase_nd<counting_value, 10>();
     BOOST_CHECK(counting_value::count() == 0);
 
+ test_insert_nd<int, 10>(50);
+ test_insert_nd<value_nd, 10>(value_nd(50));
+ test_insert_nd<counting_value, 10>(counting_value(50));
+ BOOST_CHECK(counting_value::count() == 0);
+
     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