Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57830 - in trunk: boost/format libs/format/test
From: Samuel.Krempp_at_[hidden]
Date: 2009-11-21 03:19:52


Author: samuel_krempp
Date: 2009-11-21 03:19:51 EST (Sat, 21 Nov 2009)
New Revision: 57830
URL: http://svn.boost.org/trac/boost/changeset/57830

Log:
fixes new functions (remaining_args, expected_args, ...) in case bound.size()==0
Text files modified:
   trunk/boost/format/format_implementation.hpp | 6 ++++++
   trunk/libs/format/test/format_test3.cpp | 35 ++++++++++++++++++++++-------------
   2 files changed, 28 insertions(+), 13 deletions(-)

Modified: trunk/boost/format/format_implementation.hpp
==============================================================================
--- trunk/boost/format/format_implementation.hpp (original)
+++ trunk/boost/format/format_implementation.hpp 2009-11-21 03:19:51 EST (Sat, 21 Nov 2009)
@@ -174,6 +174,8 @@
     template< class Ch, class Tr, class Alloc>
     int basic_format<Ch,Tr, Alloc>::
     bound_args() const {
+ if(bound_.size()==0)
+ return 0;
             int n=0;
             for(int i=0; i<num_args_ ; ++i)
                     if(bound_[i])
@@ -184,6 +186,8 @@
     template< class Ch, class Tr, class Alloc>
     int basic_format<Ch,Tr, Alloc>::
     fed_args() const {
+ if(bound_.size()==0)
+ return cur_arg_;
             int n=0;
             for(int i=0; i<cur_arg_ ; ++i)
                     if(!bound_[i])
@@ -199,6 +203,8 @@
     template< class Ch, class Tr, class Alloc>
     int basic_format<Ch,Tr, Alloc>::
     remaining_args() const {
+ if(bound_.size()==0)
+ return num_args_-cur_arg_;
             int n=0;
             for(int i=cur_arg_; i<num_args_ ; ++i)
                     if(!bound_[i])

Modified: trunk/libs/format/test/format_test3.cpp
==============================================================================
--- trunk/libs/format/test/format_test3.cpp (original)
+++ trunk/libs/format/test/format_test3.cpp 2009-11-21 03:19:51 EST (Sat, 21 Nov 2009)
@@ -94,21 +94,30 @@
     }
 
     // bind args, and various arguments counts :
- boost::format bf("%1% %4% %1%");
- bf.bind_arg(1, "one") % 2 % "three" ;
- BOOST_CHECK_EQUAL(bf.expected_args(), 4);
- BOOST_CHECK_EQUAL(bf.fed_args(), 2);
- BOOST_CHECK_EQUAL(bf.bound_args(), 1);
- BOOST_CHECK_EQUAL(bf.remaining_args(), 1);
- BOOST_CHECK_EQUAL(bf.cur_arg(), 4);
-
-
+ {
+ boost::format bf("%1% %4% %1%");
+ bf.bind_arg(1, "one") % 2 % "three" ;
+ BOOST_CHECK_EQUAL(bf.expected_args(), 4);
+ BOOST_CHECK_EQUAL(bf.fed_args(), 2);
+ BOOST_CHECK_EQUAL(bf.bound_args(), 1);
+ BOOST_CHECK_EQUAL(bf.remaining_args(), 1);
+ BOOST_CHECK_EQUAL(bf.cur_arg(), 4);
+ bf.clear_binds();
+ bf % "one" % 2 % "three" ;
+ BOOST_CHECK_EQUAL(bf.expected_args(), 4);
+ BOOST_CHECK_EQUAL(bf.fed_args(), 3);
+ BOOST_CHECK_EQUAL(bf.bound_args(), 0);
+ BOOST_CHECK_EQUAL(bf.remaining_args(), 1);
+ BOOST_CHECK_EQUAL(bf.cur_arg(), 4);
+ }
     // testcase for bug reported at
     // http://lists.boost.org/boost-users/2006/05/19723.php
- format f("%40t%1%");
- int x = 0;
- f.bind_arg(1, x);
- f.clear();
+ {
+ format f("%40t%1%");
+ int x = 0;
+ f.bind_arg(1, x);
+ f.clear();
+ }
 
     // testcase for bug reported at
     // http://lists.boost.org/boost-users/2005/11/15454.php


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