Boost logo

Boost-Commit :

From: jurko.gospodnetic_at_[hidden]
Date: 2008-06-07 12:45:04


Author: jurko
Date: 2008-06-07 12:45:04 EDT (Sat, 07 Jun 2008)
New Revision: 46216
URL: http://svn.boost.org/trac/boost/changeset/46216

Log:
Corrected the vector.insert rule so it works correctly when given an index lager than the number of elements in the given vector (patch by Rick Yang). Added new related tests.
Text files modified:
   trunk/tools/build/v2/util/container.jam | 23 ++++++++++++++++++++++-
   1 files changed, 22 insertions(+), 1 deletions(-)

Modified: trunk/tools/build/v2/util/container.jam
==============================================================================
--- trunk/tools/build/v2/util/container.jam (original)
+++ trunk/tools/build/v2/util/container.jam 2008-06-07 12:45:04 EDT (Sat, 07 Jun 2008)
@@ -153,8 +153,11 @@
         )
     {
         local left = $(self.value[1-$(index)]) ;
- left = $(left[1--2]) ;
         local right = $(self.value[$(index)-]) ;
+ if $(right)-is-defined
+ {
+ left = $(left[1--2]) ;
+ }
         self.value = $(left) $(value) $(right) ;
     }
 
@@ -316,4 +319,22 @@
 
     local v6 = [ new vector [ new vector 1 2 3 ] ] ;
     assert.true $(v6).equal [ new vector [ new vector 1 2 3 ] ] ;
+
+ local v7 = [ new vector 111 222 333 ] ;
+ $(v7).insert 4 : 444 ;
+ assert.result 111 222 333 444 : $(v7).get ;
+ $(v7).insert 999 : xxx ;
+ assert.result 111 222 333 444 xxx : $(v7).get ;
+
+ local v8 = [ new vector "" "" "" ] ;
+ assert.result 3 : $(v8).size ;
+ $(v8).insert 2 : 222 ;
+ assert.result 4 : $(v8).size ;
+ assert.result "" 222 "" "" : $(v8).get ;
+ $(v8).insert 999 : "" ;
+ assert.result 5 : $(v8).size ;
+ assert.result "" 222 "" "" "" : $(v8).get ;
+ $(v8).insert 999 : xxx ;
+ assert.result 6 : $(v8).size ;
+ assert.result "" 222 "" "" "" xxx : $(v8).get ;
 }


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