Boost logo

Boost-Commit :

From: jefffaust_at_[hidden]
Date: 2007-05-27 19:26:26


Author: jefffaust
Date: 2007-05-27 19:26:26 EDT (Sun, 27 May 2007)
New Revision: 4324
URL: http://svn.boost.org/trac/boost/changeset/4324

Log:
Add wrapper to support boost.range

Text files modified:
   sandbox/explore/libs/explore/test/Jamfile.v2 | 3 -
   sandbox/explore/libs/explore/test/boost_range.cpp | 42 ++++++++++++++++++++++++++++++---------
   2 files changed, 33 insertions(+), 12 deletions(-)

Modified: sandbox/explore/libs/explore/test/Jamfile.v2
==============================================================================
--- sandbox/explore/libs/explore/test/Jamfile.v2 (original)
+++ sandbox/explore/libs/explore/test/Jamfile.v2 2007-05-27 19:26:26 EDT (Sun, 27 May 2007)
@@ -34,8 +34,7 @@
   [ run boost_tuple.cpp ]
   [ run boost_variant.cpp ]
   
- # conflicts with stream operator already defined for iterator_range
- #[ run boost_range.cpp ]
+ [ run boost_range.cpp ]
   
   [ run custom_format_simple.cpp ]
  ;

Modified: sandbox/explore/libs/explore/test/boost_range.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/boost_range.cpp (original)
+++ sandbox/explore/libs/explore/test/boost_range.cpp 2007-05-27 19:26:26 EDT (Sun, 27 May 2007)
@@ -12,53 +12,75 @@
 #include <sstream>
 #include <vector>
 #include <boost/range/iterator_range.hpp>
-#include "../../../boost/explore/explore.hpp"
 #include "../../../boost/explore/stream_container.hpp"
 
-BOOST_AUTO_TEST_CASE( boost_range_print_test )
+//what's up here? I get a link error if I include explore.hpp
+//#include "../../../boost/explore/explore.hpp"
+
+BOOST_AUTO_TEST_CASE( boost_range_stream_test )
 {
+ using namespace explore;
     std::stringstream str_out;
 
     typedef std::vector<int> Cont;
     typedef boost::iterator_range<Cont::iterator> IterRange;
+ typedef boost::iterator_range<Cont::reverse_iterator> RevIterRange;
     Cont vi;
- explore::print(IterRange(vi), str_out);
+ str_out << as_container(IterRange(vi));
     BOOST_CHECK_EQUAL(str_out.str(), "[]");
 
     str_out.str("");
 
     vi.push_back(1);
- explore::print(IterRange(vi), str_out);
+ str_out << as_container(IterRange(vi));
     BOOST_CHECK_EQUAL(str_out.str(), "[1]");
 
     str_out.str("");
 
     vi.push_back(2);
     vi.push_back(3);
- explore::print(IterRange(vi), str_out);
+ str_out << as_container(IterRange(vi));
     BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+
+ str_out.str("");
+ str_out << as_container(IterRange(vi.begin()+2, vi.end()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[3]");
+
+ str_out.str("");
+ str_out << as_container(RevIterRange(vi.rbegin(), vi.rend()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[3, 2, 1]");
 }
 
-BOOST_AUTO_TEST_CASE( boost_range_stream_test )
+#include "../../../boost/explore/explore.hpp"
+BOOST_AUTO_TEST_CASE( boost_range_print_test )
 {
     std::stringstream str_out;
 
     typedef std::vector<int> Cont;
- typedef iterator_range<Cont::iterator> IterRange;
+ typedef boost::iterator_range<Cont::iterator> IterRange;
+ typedef boost::iterator_range<Cont::reverse_iterator> RevIterRange;
     Cont vi;
- str_out << IterRange(vi);
+ explore::print(IterRange(vi), str_out);
     BOOST_CHECK_EQUAL(str_out.str(), "[]");
 
     str_out.str("");
 
     vi.push_back(1);
- str_out << IterRange(vi);
+ explore::print(IterRange(vi), str_out);
     BOOST_CHECK_EQUAL(str_out.str(), "[1]");
 
     str_out.str("");
 
     vi.push_back(2);
     vi.push_back(3);
- str_out << IterRange(vi);
+ explore::print(IterRange(vi), str_out);
     BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+
+ str_out.str("");
+ explore::print(IterRange(vi.begin()+2, vi.end()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[3]");
+
+ str_out.str("");
+ explore::print(RevIterRange(vi.rbegin(), vi.rend()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[3, 2, 1]");
 }


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