Boost logo

Boost-Commit :

From: marshall_at_[hidden]
Date: 2008-06-21 22:11:10


Author: marshall
Date: 2008-06-21 22:11:09 EDT (Sat, 21 Jun 2008)
New Revision: 46599
URL: http://svn.boost.org/trac/boost/changeset/46599

Log:
Fixed tests
Text files modified:
   sandbox/boost/algorithm/copy.hpp | 3 +
   sandbox/libs/algorithm/copy/test/copy_test.cpp | 62 ++++++++++++++++++++-------------------
   2 files changed, 34 insertions(+), 31 deletions(-)

Modified: sandbox/boost/algorithm/copy.hpp
==============================================================================
--- sandbox/boost/algorithm/copy.hpp (original)
+++ sandbox/boost/algorithm/copy.hpp 2008-06-21 22:11:09 EDT (Sat, 21 Jun 2008)
@@ -12,6 +12,7 @@
 #define BOOST_ALGORITHM_SEQUENCE_COPY_HPP
 
 #include <boost/range.hpp> // For boost::begin and boost::end
+#include <iterator> // for std::iterator_traits<>
 
 /// \file copy.hpp
 /// \brief Boost implementation of various STL-type copying algorithms
@@ -199,7 +200,7 @@
 // template <typename I, typename Size, typename O>
 // O copy_n ( I first, Size count, O res )
   template <typename I, typename O>
- O copy_n ( I first, typename iterator_traits<I>::difference_type count, O res )
+ O copy_n ( I first, typename std::iterator_traits<I>::difference_type count, O res )
   {
     while ( count-- > 0 )
       *res++ = *first++;

Modified: sandbox/libs/algorithm/copy/test/copy_test.cpp
==============================================================================
--- sandbox/libs/algorithm/copy/test/copy_test.cpp (original)
+++ sandbox/libs/algorithm/copy/test/copy_test.cpp 2008-06-21 22:11:09 EDT (Sat, 21 Jun 2008)
@@ -3,13 +3,13 @@
 // 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 <utility>
-#include <functional>
-
 #include <boost/config.hpp>
 #include <boost/algorithm/copy.hpp>
 #include <boost/test/included/test_exec_monitor.hpp>
 
+#include <utility>
+#include <functional>
+
 // #include <boost/algorithm/all.hpp>
 // #include <boost/algorithm/select.hpp>
 
@@ -20,6 +20,8 @@
 bool IsEven ( int v2 ) { return ( v2 & 1 ) == 0; }
 bool IsOdd ( int v2 ) { return ( v2 & 1 ) != 0; }
 
+namespace bas = boost::algorithm::sequence;
+
 void test_copy_if ()
 {
   const int vals [] = { 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1 };
@@ -33,36 +35,36 @@
 
 // Copy_if from constant iterators
   res.clear ();
- boost::algorithm::copy_if ( vals, vals + valsSize, std::back_inserter(res), IsEqual<0> );
+ bas::copy_if ( vals, vals + valsSize, std::back_inserter(res), IsEqual<0> );
   BOOST_CHECK_EQUAL ( res.size (), 5U );
   BOOST_CHECK ( std::find_if ( res.begin (), res.end (), IsNotEqual<0> ) == res.end ());
 
 // Copy them all
   res.clear ();
- boost::algorithm::copy_if ( vals, vals + valsSize, std::back_inserter(res), IsLess<100> );
+ bas::copy_if ( vals, vals + valsSize, std::back_inserter(res), IsLess<100> );
   BOOST_CHECK_EQUAL ( valsSize, res.size ());
   BOOST_CHECK ( std::equal ( vals, vals + valsSize, res.begin ()));
 
 // Copy none
   res.clear ();
- boost::algorithm::copy_if ( vals, vals + valsSize, std::back_inserter(res), IsGreater<100> );
+ bas::copy_if ( vals, vals + valsSize, std::back_inserter(res), IsGreater<100> );
   BOOST_CHECK_EQUAL ( 0U, res.size ());
 
 // Copy_if using ranges
   res.clear ();
- boost::algorithm::copy_if ( cont, std::back_inserter(res), IsNotEqual<0> );
+ bas::copy_if ( cont, std::back_inserter(res), IsNotEqual<0> );
   BOOST_CHECK_EQUAL ( res.size (), 5U );
   BOOST_CHECK ( std::find_if ( res.begin (), res.end (), IsEqual<0> ) == res.end ());
 
 // Copy them all
   res.clear ();
- boost::algorithm::copy_if ( cont, std::back_inserter(res), IsNotEqual<2> );
+ bas::copy_if ( cont, std::back_inserter(res), IsNotEqual<2> );
   BOOST_CHECK_EQUAL ( cont.size (), res.size ());
   BOOST_CHECK ( std::equal ( cont.begin (), cont.end (), res.begin ()));
 
 // Copy none
   res.clear ();
- boost::algorithm::copy_if ( cont, std::back_inserter(res), IsEqual<2> );
+ bas::copy_if ( cont, std::back_inserter(res), IsEqual<2> );
   BOOST_CHECK_EQUAL ( 0U, res.size ());
 
 // ---- Backwards tests ----
@@ -75,7 +77,7 @@
 
 // Copy_if_backward from constant iterators
   res.clear ();
- boost::algorithm::copy_if_backward ( vals2, vals2 + vals2Size, std::back_inserter(res), IsEven );
+ bas::copy_backward_if ( vals2, vals2 + vals2Size, std::back_inserter(res), IsEven );
   BOOST_CHECK_EQUAL ( res.size (), 5U );
   BOOST_CHECK_EQUAL ( res[0], 8 );
   BOOST_CHECK_EQUAL ( res[1], 6 );
@@ -85,19 +87,19 @@
 
 // Copy them all
   res.clear ();
- boost::algorithm::copy_if_backward ( vals2, vals2 + vals2Size, std::back_inserter(res), IsLess<100> );
+ bas::copy_backward_if ( vals2, vals2 + vals2Size, std::back_inserter(res), IsLess<100> );
   BOOST_CHECK_EQUAL ( vals2Size, res.size ());
   BOOST_CHECK ( std::equal ( vals2, vals2 + vals2Size, res.rbegin ()));
 
 // Copy none
   res.clear ();
- boost::algorithm::copy_if_backward ( vals, vals + valsSize, std::back_inserter(res), IsGreater<100> );
+ bas::copy_backward_if ( vals, vals + valsSize, std::back_inserter(res), IsGreater<100> );
   BOOST_CHECK_EQUAL ( 0U, res.size ());
 
 
 // Copy_if_backward using ranges
   res.clear ();
- boost::algorithm::copy_if_backward ( cont, std::back_inserter(res), IsEven );
+ bas::copy_backward_if ( cont, std::back_inserter(res), IsEven );
   BOOST_CHECK_EQUAL ( res.size (), 5U );
   BOOST_CHECK_EQUAL ( res[0], 8 );
   BOOST_CHECK_EQUAL ( res[1], 6 );
@@ -107,13 +109,13 @@
 
 // Copy them all
   res.clear ();
- boost::algorithm::copy_if_backward ( cont, std::back_inserter(res), IsLess<100> );
+ bas::copy_backward_if ( cont, std::back_inserter(res), IsLess<100> );
   BOOST_CHECK_EQUAL ( cont.size (), res.size ());
   BOOST_CHECK ( std::equal ( cont.rbegin (), cont.rend (), res.begin ()));
 
 // Copy none
   res.clear ();
- boost::algorithm::copy_if_backward ( vals, vals + valsSize, std::back_inserter(res), IsGreater<100> );
+ bas::copy_backward_if ( vals, vals + valsSize, std::back_inserter(res), IsGreater<100> );
   BOOST_CHECK_EQUAL ( 0U, res.size ());
 }
 
@@ -130,36 +132,36 @@
 
 // Copy_while from constant iterators
   res.clear ();
- boost::algorithm::copy_while ( vals, vals + valsSize, std::back_inserter(res), IsEqual<0> );
+ bas::copy_while ( vals, vals + valsSize, std::back_inserter(res), IsEqual<0> );
   BOOST_CHECK_EQUAL ( res.size (), 1U );
   BOOST_CHECK_EQUAL ( res[0], 0 );
 
 // Copy them all
   res.clear ();
- boost::algorithm::copy_while ( vals, vals + valsSize, std::back_inserter(res), IsLess<100> );
+ bas::copy_while ( vals, vals + valsSize, std::back_inserter(res), IsLess<100> );
   BOOST_CHECK_EQUAL ( valsSize, res.size ());
   BOOST_CHECK ( std::equal ( vals, vals + valsSize, res.begin ()));
 
 // Copy none
   res.clear ();
- boost::algorithm::copy_while ( vals, vals + valsSize, std::back_inserter(res), IsGreater<100> );
+ bas::copy_while ( vals, vals + valsSize, std::back_inserter(res), IsGreater<100> );
   BOOST_CHECK_EQUAL ( 0U, res.size ());
 
 // Copy_while using ranges
   res.clear ();
- boost::algorithm::copy_while ( cont, std::back_inserter(res), IsNotEqual<1> );
+ bas::copy_while ( cont, std::back_inserter(res), IsNotEqual<1> );
   BOOST_CHECK_EQUAL ( res.size (), 1U );
   BOOST_CHECK_EQUAL ( res[0], 0 );
 
 // Copy them all
   res.clear ();
- boost::algorithm::copy_while ( cont, std::back_inserter(res), IsNotEqual<2> );
+ bas::copy_while ( cont, std::back_inserter(res), IsNotEqual<2> );
   BOOST_CHECK_EQUAL ( cont.size (), res.size ());
   BOOST_CHECK ( std::equal ( cont.begin (), cont.end (), res.begin ()));
 
 // Copy none
   res.clear ();
- boost::algorithm::copy_while ( cont, std::back_inserter(res), IsEqual<2> );
+ bas::copy_while ( cont, std::back_inserter(res), IsEqual<2> );
   BOOST_CHECK_EQUAL ( 0U, res.size ());
 
 // ---- Backwards tests ----
@@ -172,7 +174,7 @@
 
 // Copy_if_backward from constant iterators
   res.clear ();
- boost::algorithm::copy_while_backward ( vals2, vals2 + vals2Size, std::back_inserter(res), IsGreater<5> );
+ bas::copy_backward_while ( vals2, vals2 + vals2Size, std::back_inserter(res), IsGreater<5> );
   BOOST_CHECK_EQUAL ( res.size (), 4U );
   BOOST_CHECK_EQUAL ( res[0], 9 );
   BOOST_CHECK_EQUAL ( res[1], 8 );
@@ -181,19 +183,19 @@
 
 // Copy them all
   res.clear ();
- boost::algorithm::copy_while_backward ( vals2, vals2 + vals2Size, std::back_inserter(res), IsLess<100> );
+ bas::copy_backward_while ( vals2, vals2 + vals2Size, std::back_inserter(res), IsLess<100> );
   BOOST_CHECK_EQUAL ( vals2Size, res.size ());
   BOOST_CHECK ( std::equal ( vals2, vals2 + vals2Size, res.rbegin ()));
 
 // Copy none
   res.clear ();
- boost::algorithm::copy_while_backward ( vals, vals + valsSize, std::back_inserter(res), IsGreater<100> );
+ bas::copy_backward_while ( vals, vals + valsSize, std::back_inserter(res), IsGreater<100> );
   BOOST_CHECK_EQUAL ( 0U, res.size ());
 
 
 // Copy_while_backward using ranges
   res.clear ();
- boost::algorithm::copy_while_backward ( cont, std::back_inserter(res), IsGreater<5> );
+ bas::copy_backward_while ( cont, std::back_inserter(res), IsGreater<5> );
   BOOST_CHECK_EQUAL ( res.size (), 3U );
   BOOST_CHECK_EQUAL ( res[0], 8 );
   BOOST_CHECK_EQUAL ( res[1], 7 );
@@ -201,13 +203,13 @@
 
 // Copy them all
   res.clear ();
- boost::algorithm::copy_while_backward ( cont, std::back_inserter(res), IsLess<100> );
+ bas::copy_backward_while ( cont, std::back_inserter(res), IsLess<100> );
   BOOST_CHECK_EQUAL ( cont.size (), res.size ());
   BOOST_CHECK ( std::equal ( cont.rbegin (), cont.rend (), res.begin ()));
 
 // Copy none
   res.clear ();
- boost::algorithm::copy_while_backward ( vals, vals + valsSize, std::back_inserter(res), IsGreater<100> );
+ bas::copy_backward_while ( vals, vals + valsSize, std::back_inserter(res), IsGreater<100> );
   BOOST_CHECK_EQUAL ( 0U, res.size ());
 }
 
@@ -224,18 +226,18 @@
 
 // copy_n from constant iterators
   res.clear ();
- boost::algorithm::copy_n ( vals, valsSize, std::back_inserter(res));
+ bas::copy_n ( vals, valsSize, std::back_inserter(res));
   BOOST_CHECK_EQUAL ( res.size (), valsSize );
   BOOST_CHECK ( std::equal ( vals, vals + valsSize, res.begin ()));
 
 // Copy none
   res.clear ();
- boost::algorithm::copy_n ( vals, 0, std::back_inserter(res));
+ bas::copy_n ( vals, 0, std::back_inserter(res));
   BOOST_CHECK_EQUAL ( 0U, res.size ());
 
 // Copy_while from container
   res.clear ();
- boost::algorithm::copy_n ( cont.begin (), cont.size (), std::back_inserter(res) );
+ bas::copy_n ( cont.begin (), cont.size (), std::back_inserter(res) );
   BOOST_CHECK_EQUAL ( res.size (), cont.size ());
   BOOST_CHECK ( std::equal ( cont.begin (), cont.end (), res.begin ()));
 }


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