Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55895 - in sandbox/explore: boost/explore libs/explore/test
From: jeff_at_[hidden]
Date: 2009-08-30 18:16:41


Author: jefffaust
Date: 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
New Revision: 55895
URL: http://svn.boost.org/trac/boost/changeset/55895

Log:
Support for wchar_t
Added:
   sandbox/explore/libs/explore/test/boost_explore_test_tools.hpp (contents, props changed)
Text files modified:
   sandbox/explore/boost/explore/container_stream_state.hpp | 121 ++++++++++++++++++++++++++++++---------
   sandbox/explore/boost/explore/manipulators.hpp | 21 ++---
   sandbox/explore/boost/explore/pair.hpp | 5
   sandbox/explore/boost/explore/stream_container.hpp | 9 +-
   sandbox/explore/boost/explore/stream_state.hpp | 4
   sandbox/explore/boost/explore/stream_value.hpp | 6
   sandbox/explore/libs/explore/test/boost_array.cpp | 39 ++++++------
   sandbox/explore/libs/explore/test/boost_range.cpp | 25 +++----
   sandbox/explore/libs/explore/test/boost_tuple.cpp | 11 +-
   sandbox/explore/libs/explore/test/boost_variant.cpp | 79 +++++++++++++------------
   sandbox/explore/libs/explore/test/c_array.cpp | 48 ++++++++++-----
   sandbox/explore/libs/explore/test/columnated.cpp | 28 ++++----
   sandbox/explore/libs/explore/test/custom_format_simple.cpp | 77 +++++++++++++-----------
   sandbox/explore/libs/explore/test/html_table_output.cpp | 29 +++++++--
   sandbox/explore/libs/explore/test/is_assoc_iter.cpp | 5
   sandbox/explore/libs/explore/test/multi_dim_test.cpp | 44 +++++++++++--
   sandbox/explore/libs/explore/test/simple_types.cpp | 59 +++++++++++--------
   sandbox/explore/libs/explore/test/std_deque.cpp | 39 ++++++------
   sandbox/explore/libs/explore/test/std_list.cpp | 39 ++++++------
   sandbox/explore/libs/explore/test/std_map.cpp | 81 +++++++++++++-------------
   sandbox/explore/libs/explore/test/std_pair.cpp | 27 ++++----
   sandbox/explore/libs/explore/test/std_set.cpp | 62 +++++++++----------
   sandbox/explore/libs/explore/test/std_vector.cpp | 53 ++++++++++-------
   sandbox/explore/libs/explore/test/user_defined_container.cpp | 39 ++++++++----
   24 files changed, 549 insertions(+), 401 deletions(-)

Modified: sandbox/explore/boost/explore/container_stream_state.hpp
==============================================================================
--- sandbox/explore/boost/explore/container_stream_state.hpp (original)
+++ sandbox/explore/boost/explore/container_stream_state.hpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -13,6 +13,7 @@
 #include <cassert>
 #include <string>
 #include <vector>
+#include <boost/explore/stream_state.hpp>
 
 // generate string init functions for both char and wchar_t types
 #define BOOST_EXPLORE_INIT_STRING(name, str) \
@@ -31,21 +32,90 @@
         BOOST_EXPLORE_INIT_STRING(assoc_start, "")
         BOOST_EXPLORE_INIT_STRING(assoc_end, "")
 
- template<typename Elem>
         struct depth_guard;
+
+ // read
+ template<typename T>
+ const T& value_at(const std::vector<T>& c, size_t level)
+ {
+ // return the highest item if it does not exist at the given index
+ return c[std::min(level, c.size() - 1)];
+ }
+
+ // write
+ template<typename T>
+ T& value_at(std::vector<T>& c, size_t level)
+ {
+ if( c.size() <= level )
+ {
+ c.resize(level+1);
+ }
+
+ return c[level];
+ }
     }
 
+ // state not dependent on character type
+ struct container_common_stream_state
+ {
+ container_common_stream_state(const std::ios_base* stream)
+ : m_level(0), m_depth(0), m_rows(1), m_itemwidth(1)
+ {
+ }
+
+ void set_level(size_t l) { m_level = l; }
+ void level_up() { ++m_level; }
+ void level_down() { --m_level; }
+
+ size_t get_level() const { return m_level; }
+ std::size_t depth() const { return m_depth; }
+
+ std::size_t rows() const { return at(m_rows); }
+ std::size_t itemwidth() const { return at(m_itemwidth); }
+
+ void set_rows(std::size_t rows) { at(m_rows) = rows; }
+ void set_itemwidth(std::size_t iw) { at(m_itemwidth) = iw; }
+
+ private:
+ friend struct detail::depth_guard;
+
+ typedef std::vector<std::size_t, std::allocator<std::size_t> > size_cont_typ;
+
+ // read
+ template<typename T>
+ const T& at(const std::vector<T>& c) const
+ {
+ // return the highest item if it does not exist at the given index
+ return detail::value_at(c, get_level());
+ }
+
+ // write
+ template<typename T>
+ T& at(std::vector<T>& c)
+ {
+ size_t level = get_level();
+ assert(depth() <= level);
+ return detail::value_at(c, get_level());
+ }
+
+ std::size_t m_level;
+ std::size_t m_depth;
+
+ size_cont_typ m_rows;
+ size_cont_typ m_itemwidth;
+ };
+
     // A simple collection of additional stream state
     template<typename Elem>
     struct container_stream_state
     {
         typedef std::basic_string<Elem> str_typ;
         typedef std::vector<str_typ, std::allocator<str_typ> > str_cont_typ;
- typedef std::vector<std::size_t, std::allocator<std::size_t> > size_cont_typ;
 
- container_stream_state()
- : m_depth(0), m_level(0)
+ explicit container_stream_state(std::ios_base* stream)
+ : m_stream(stream)
         {
+ assert(m_stream);
             init<Elem>();
         }
 
@@ -60,8 +130,6 @@
             init(m_assoc_separator, detail::init_assoc_separator<El>());
             init(m_assoc_start, detail::init_assoc_start<El>());
             init(m_assoc_end, detail::init_assoc_end<El>());
- m_rows.resize(1, 0);
- m_itemwidth.resize(1, 0);
         }
 
         // read
@@ -71,8 +139,6 @@
         const str_typ& assoc_separator() const { return at(m_assoc_separator); }
         const str_typ& assoc_start() const { return at(m_assoc_start); }
         const str_typ& assoc_end() const { return at(m_assoc_end); }
- std::size_t rows() const { return at(m_rows); }
- std::size_t itemwidth() const { return at(m_itemwidth); }
 
         // write
         void set_separator(const str_typ& str) { at(m_separator) = str; }
@@ -81,17 +147,22 @@
         void set_assoc_separator(const str_typ& str) { at(m_assoc_separator) = str; }
         void set_assoc_start(const str_typ& str) { at(m_assoc_start) = str; }
         void set_assoc_end(const str_typ& str) { at(m_assoc_end) = str; }
- void set_rows(std::size_t rows) { at(m_rows) = rows; }
- void set_itemwidth(std::size_t iw) { at(m_itemwidth) = iw; }
 
- void set_level(size_t l) { m_level = l; }
- void level_up() { ++m_level; }
- void level_down() { --m_level; }
+ private:
+ container_common_stream_state* common()
+ {
+ return get_stream_state<container_common_stream_state>(*m_stream);
+ }
 
- std::size_t depth() const { return m_depth; }
+ const container_common_stream_state* common() const
+ {
+ return get_stream_state<container_common_stream_state>(*m_stream);
+ }
 
- private:
- friend struct detail::depth_guard<Elem>;
+ size_t get_level() const
+ {
+ return common()->get_level();
+ }
 
         str_cont_typ m_separator;
         str_cont_typ m_start;
@@ -99,11 +170,8 @@
         str_cont_typ m_assoc_separator;
         str_cont_typ m_assoc_start;
         str_cont_typ m_assoc_end;
- std::size_t m_depth;
- std::size_t m_level;
 
- size_cont_typ m_rows;
- size_cont_typ m_itemwidth;
+ std::ios_base* m_stream;
 
         template<typename T>
         void init(str_cont_typ& c, const T& val)
@@ -117,21 +185,16 @@
         const T& at(const std::vector<T>& c) const
         {
             // return the highest item if it does not exist at the given index
- return c[std::min(m_level, c.size() - 1)];
+ return detail::value_at(c, get_level());
         }
 
         // write
         template<typename T>
         T& at(std::vector<T>& c)
         {
- assert(m_depth <= m_level);
-
- if( c.size() <= m_level )
- {
- c.resize(m_level+1);
- }
-
- return c[m_level];
+ size_t level = get_level();
+ assert(common()->depth() <= level);
+ return detail::value_at(c, get_level());
         }
     };
 }}

Modified: sandbox/explore/boost/explore/manipulators.hpp
==============================================================================
--- sandbox/explore/boost/explore/manipulators.hpp (original)
+++ sandbox/explore/boost/explore/manipulators.hpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -19,11 +19,10 @@
 {
     namespace detail
     {
- template<typename Elem>
         struct depth_guard
         {
- depth_guard(container_stream_state<Elem>* state)
- : m_state(state), m_prev_level(state->m_level)
+ depth_guard(container_common_stream_state* state)
+ : m_state(state), m_prev_level(state->get_level())
             {
                 ++m_state->m_depth;
             }
@@ -31,11 +30,11 @@
             ~depth_guard()
             {
                 --m_state->m_depth;
- m_state->m_level = m_prev_level;
+ m_state->set_level(m_prev_level);
             }
             
         private:
- container_stream_state<Elem>* m_state;
+ container_common_stream_state* m_state;
             size_t m_prev_level;
         };
         
@@ -76,13 +75,13 @@
                 }
             }
 
- container_stream_state<char>* m_state;
+ container_common_stream_state* m_state;
         };
 
         template<typename Elem, typename Tr>
         std::basic_ostream<Elem, Tr>& operator<<(std::basic_ostream<Elem, Tr>& ostr, handle_custom_stream& cs)
         {
- container_stream_state<Elem>* state = explore::get_stream_state<container_stream_state<Elem> >(ostr);
+ container_common_stream_state* state = explore::get_stream_state<container_common_stream_state>(ostr);
             cs.m_state = state;
             if( state->depth() > 0 ) // only needed if nested
             {
@@ -136,21 +135,19 @@
 
         void levelFn(std::ios_base& ostr, std::size_t l)
         {
- explore::get_stream_state<container_stream_state<char> >(ostr)->set_level(l);
+ explore::get_stream_state<container_common_stream_state>(ostr)->set_level(l);
         }
 
         // function ptr object for setrows
- //template<typename Elem>
         void setrowsFn(std::ios_base& ostr, std::size_t sz)
         {
- explore::get_stream_state<container_stream_state<char> >(ostr)->set_rows(sz);
+ explore::get_stream_state<container_common_stream_state>(ostr)->set_rows(sz);
         }
         
         // function ptr object for setrows
- //template<typename Elem>
         void setitemwidthFn(std::ios_base& ostr, std::size_t sz)
         {
- explore::get_stream_state<container_stream_state<char> >(ostr)->set_itemwidth(sz);
+ explore::get_stream_state<container_common_stream_state>(ostr)->set_itemwidth(sz);
         }
     }
     

Modified: sandbox/explore/boost/explore/pair.hpp
==============================================================================
--- sandbox/explore/boost/explore/pair.hpp (original)
+++ sandbox/explore/boost/explore/pair.hpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -20,9 +20,10 @@
     std::basic_ostream<Elem, Tr>& operator<<(std::basic_ostream<Elem, Tr>& ostr, const std::pair<T1, T2>& p)
     {
         using namespace boost::explore;
+ container_common_stream_state* common_state = get_stream_state<container_common_stream_state>(ostr);
+ detail::depth_guard guard(common_state);
+ common_state->set_level(common_state->depth()-1);
         container_stream_state<Elem>* state = get_stream_state<container_stream_state<Elem> >(ostr);
- detail::depth_guard<Elem> guard(state);
- state->set_level(state->depth()-1);
         return ostr << state->start() << p.first << state->separator() << p.second << state->end();
     }
 }

Modified: sandbox/explore/boost/explore/stream_container.hpp
==============================================================================
--- sandbox/explore/boost/explore/stream_container.hpp (original)
+++ sandbox/explore/boost/explore/stream_container.hpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -24,19 +24,20 @@
     {
         // grab the extra data embedded in the stream object.
         container_stream_state<Elem>* state = explore::get_stream_state<container_stream_state<Elem> >(ostr);
- detail::depth_guard<Elem> guard(state);
- state->set_level(state->depth()-1);
+ container_common_stream_state* common_state = explore::get_stream_state<container_common_stream_state>(ostr);
+ detail::depth_guard guard(common_state);
+ common_state->set_level(common_state->depth()-1);
 
         // starting delimiter
         ostr << state->start();
 
- std::size_t rows = state->rows();
+ std::size_t rows = common_state->rows();
 
         std::size_t cur_row = 0;
         while( first != last )
         {
             // value
- f(ostr, *first, state);
+ f(ostr, *first, state, common_state);
 
             if( ++first != last )
             {

Modified: sandbox/explore/boost/explore/stream_state.hpp
==============================================================================
--- sandbox/explore/boost/explore/stream_state.hpp (original)
+++ sandbox/explore/boost/explore/stream_state.hpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -47,7 +47,7 @@
     // returns state information stored in the stream for the given type. Will allocate
     // state data if needed and create == true. If create == false and the data does not
     // already exist, it will return 0.
- // T: the user-defined state class. Must be default constructible.
+ // T: the user-defined state class. Must be constructible, accepting a stream pointer.
     template<typename T>
     T* get_stream_state(std::ios_base& stream, bool create)
     {
@@ -60,7 +60,7 @@
         {
             // both creating a new T and registering the callback allocate memory. Use
             // auto_ptr to satisfy the strong exception guarantee.
- std::auto_ptr<T> pt(new T);
+ std::auto_ptr<T> pt(new T(&stream));
             stream.register_callback(detail::delete_extra_state<T>, index);
             state = pt.release();
         }

Modified: sandbox/explore/boost/explore/stream_value.hpp
==============================================================================
--- sandbox/explore/boost/explore/stream_value.hpp (original)
+++ sandbox/explore/boost/explore/stream_value.hpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -19,9 +19,9 @@
     struct stream_normal_value
     {
         template<typename Elem, typename Tr, typename T>
- void operator()(std::basic_ostream<Elem, Tr>& ostr, const T& val, container_stream_state<Elem>* state)
+ void operator()(std::basic_ostream<Elem, Tr>& ostr, const T& val, container_stream_state<Elem>* state, container_common_stream_state* common_state)
         {
- ostr.width(state->itemwidth());
+ ostr.width(common_state->itemwidth());
             ostr << val;
         }
     };
@@ -30,7 +30,7 @@
     struct stream_associative_value
     {
         template<typename Elem, typename Tr, typename T>
- void operator()(std::basic_ostream<Elem, Tr>& ostr, const T& val, container_stream_state<Elem>* state)
+ void operator()(std::basic_ostream<Elem, Tr>& ostr, const T& val, container_stream_state<Elem>* state, container_common_stream_state* common_state)
         {
             ostr << state->assoc_start() << val.first << state->assoc_separator() << val.second << state->assoc_end();
         }

Modified: sandbox/explore/libs/explore/test/boost_array.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/boost_array.cpp (original)
+++ sandbox/explore/libs/explore/test/boost_array.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,44 +9,43 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <string>
-#include <sstream>
 #include <boost/array.hpp>
 #include <boost/explore/boost_array.hpp>
 #include <boost/explore/vector.hpp>
 #include <boost/explore/iterator_range.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( basic_array_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE(basic_array_stream_test, C, test_types)
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     boost::array<int,0> ai0;
     str_out << ai0;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     boost::array<int,1> ai1 = {1};
     str_out << ai1;
- BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1]");
 
- str_out.str("");
+ reset(str_out);
 
     boost::array<int,3> ai3 = {1, 2, 3};
     str_out << ai3;
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2, 3]");
 
- str_out.str("");
+ reset(str_out);
 
     boost::array<int,3>::iterator itr = ai3.begin() + 2;
 
     str_out << boost::explore::make_iterator_range(ai3.begin(), itr);
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2]");
 }
 
-BOOST_AUTO_TEST_CASE( vector_in_array_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE(vector_in_array_stream_test, C, test_types)
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::vector<int> vi;
     vi.push_back(1);
@@ -55,23 +54,23 @@
 
     boost::array<std::vector<int>,0> av0;
     str_out << av0;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     boost::array<std::vector<int>,1> av1 = {vi};
     str_out << av1;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     boost::array<std::vector<int>,3> av3 = {vi, vi, vi};
     str_out << av3;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     boost::array<std::vector<int>,3>::iterator itr = av3.begin() + 2;
     str_out << boost::explore::make_iterator_range(av3.begin(), itr);
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3]]");
 }

Added: sandbox/explore/libs/explore/test/boost_explore_test_tools.hpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/boost_explore_test_tools.hpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -0,0 +1,81 @@
+#ifndef BOOST_EXPLORE_TEST_TOOLS_H
+#define BOOST_EXPLORE_TEST_TOOLS_H
+
+// Boost.Explore library
+
+// Copyright Jeffrey Faust 2009. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+// some testing tools to help test both char and wchar_t streams
+
+#include <boost/mpl/list.hpp>
+
+#include <sstream>
+#include <string>
+#include <list>
+
+typedef boost::mpl::list<char, wchar_t> test_types;
+
+template<typename C>
+struct test_traits;
+
+template<>
+struct test_traits<char>
+{
+ typedef std::stringstream stream_type;
+ typedef std::string string_type;
+};
+
+template<>
+struct test_traits<wchar_t>
+{
+ typedef std::wstringstream stream_type;
+ typedef std::wstring string_type;
+};
+
+void reset(std::stringstream& s)
+{
+ s.str("");
+}
+
+void reset(std::wstringstream& s)
+{
+ s.str(L"");
+}
+
+std::string output(const std::stringstream& s)
+{
+ return s.str();
+}
+
+std::string output(const std::wstringstream& s)
+{
+ std::wstring ws = s.str();
+ return std::string(ws.begin(), ws.end());
+}
+
+template<typename C>
+const C* str_to(const char* in);
+
+template<>
+const char* str_to<char>(const char* in)
+{
+ return in;
+}
+
+template<>
+const wchar_t* str_to<wchar_t>(const char* in)
+{
+ // we never free this memory. OK for tests.
+ static std::list<std::wstring> storage;
+ std::string instr(in);
+ storage.push_back(std::wstring(instr.begin(), instr.end()));
+ std::wstring& out = storage.back();
+ return out.c_str();
+}
+
+#endif

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 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,37 +9,36 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <sstream>
-#include <vector>
 #include <boost/range/iterator_range.hpp>
 #include <boost/explore.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( boost_range_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( boost_range_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::vector<int> vi;
     str_out << boost::explore::make_iterator_range(vi);
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     vi.push_back(1);
     str_out << boost::explore::make_iterator_range(vi);
- BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1]");
 
- str_out.str("");
+ reset(str_out);
 
     vi.push_back(2);
     vi.push_back(3);
     str_out << boost::explore::make_iterator_range(vi);
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2, 3]");
 
- str_out.str("");
+ reset(str_out);
     str_out << boost::explore::make_iterator_range(vi.begin()+2, vi.end());
- BOOST_CHECK_EQUAL(str_out.str(), "[3]");
+ BOOST_CHECK_EQUAL(output(str_out), "[3]");
 
- str_out.str("");
+ reset(str_out);
     str_out << boost::explore::make_iterator_range(vi.rbegin(), vi.rend());
- BOOST_CHECK_EQUAL(str_out.str(), "[3, 2, 1]");
+ BOOST_CHECK_EQUAL(output(str_out), "[3, 2, 1]");
 }

Modified: sandbox/explore/libs/explore/test/boost_tuple.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/boost_tuple.cpp (original)
+++ sandbox/explore/libs/explore/test/boost_tuple.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,19 +9,18 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <string>
-#include <sstream>
 #include <boost/tuple/tuple.hpp>
 #include <boost/tuple/tuple_io.hpp>
 #include <boost/explore.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( basic_tuple_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_tuple_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     boost::tuples::tuple<int, double> t(1, 3.14);
     str_out << t;
     // I think things that already have a way to print should not change
- //BOOST_CHECK_EQUAL(str_out.str(), "[1, 3.14]");
- BOOST_CHECK_EQUAL(str_out.str(), "(1 3.14)");
+ //BOOST_CHECK_EQUAL(output(str_out), "[1, 3.14]");
+ BOOST_CHECK_EQUAL(output(str_out), "(1 3.14)");
 }

Modified: sandbox/explore/libs/explore/test/boost_variant.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/boost_variant.cpp (original)
+++ sandbox/explore/libs/explore/test/boost_variant.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,28 +9,28 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <string>
-#include <sstream>
 #include <boost/variant.hpp>
 #include <boost/explore.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( basic_variant_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_variant_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ typedef test_traits<C>::string_type string_type;
+ test_traits<C>::stream_type str_out;
 
- boost::variant< int, std::string, std::vector<int> > varVal;
+ boost::variant< int, string_type, std::vector<int> > varVal;
 
     varVal = 1;
     str_out << varVal;
- BOOST_CHECK_EQUAL(str_out.str(), "1");
+ BOOST_CHECK_EQUAL(output(str_out), "1");
 
- str_out.str("");
+ reset(str_out);
 
- varVal = std::string("some string");
+ varVal = string_type(str_to<C>("some string"));
     str_out << varVal;
- BOOST_CHECK_EQUAL(str_out.str(), "some string");
+ BOOST_CHECK_EQUAL(output(str_out), "some string");
 
- str_out.str("");
+ reset(str_out);
 
     std::vector<int> vi;
     vi.push_back(1);
@@ -38,37 +38,38 @@
     vi.push_back(3);
     varVal = vi;
     str_out << varVal;
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2, 3]");
 }
 
-BOOST_AUTO_TEST_CASE( cool_variant_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( cool_variant_stream_test, C, test_types )
 {
- using namespace boost::explore;
- std::stringstream str_out;
+ using namespace boost::explore;
+ typedef test_traits<C>::string_type string_type;
+ test_traits<C>::stream_type str_out;
+
+ std::vector<boost::variant< int, string_type, std::vector<int> > > varVec;
+ string_type name(str_to<C>("Joe"));
+
+ std::vector<int> favoriteNumbers;
+ favoriteNumbers.push_back(22);
+ favoriteNumbers.push_back(42);
+ favoriteNumbers.push_back(73);
+
+ varVec.push_back(str_to<C>("Hello, my name is "));
+ varVec.push_back(name);
+ varVec.push_back(str_to<C>(". I am "));
+ varVec.push_back(34);
+ varVec.push_back(str_to<C>(" years old. My favorite numbers are: "));
+ varVec.push_back(favoriteNumbers);
+ varVec.push_back(str_to<C>("."));
+
+ str_out << level(0);
+ str_out << start(str_to<C>("")) << boost::explore::end(str_to<C>("")) << separator(str_to<C>(""));
+
+ // level 1 (for nested collection)
+ str_out << level(1);
+ str_out << start(str_to<C>("[")) << boost::explore::end(str_to<C>("]")) << separator(str_to<C>(", "));
 
- std::vector<boost::variant< int, std::string, std::vector<int> > > varVec;
- std::string name("Joe");
-
- std::vector<int> favoriteNumbers;
- favoriteNumbers.push_back(22);
- favoriteNumbers.push_back(42);
- favoriteNumbers.push_back(73);
-
- varVec.push_back("Hello, my name is ");
- varVec.push_back(name);
- varVec.push_back(". I am ");
- varVec.push_back(34);
- varVec.push_back(" years old. My favorite numbers are: ");
- varVec.push_back(favoriteNumbers);
- varVec.push_back(".");
-
- str_out << level(0);
- str_out << start("") << boost::explore::end("") << separator("");
-
- // level 1 (for nested collection)
- str_out << level(1);
- str_out << start("[") << boost::explore::end("]") << separator(", ");
-
- str_out << varVec;
- BOOST_CHECK_EQUAL(str_out.str(), "Hello, my name is Joe. I am 34 years old. My favorite numbers are: [22, 42, 73].");
+ str_out << varVec;
+ BOOST_CHECK_EQUAL(output(str_out), "Hello, my name is Joe. I am 34 years old. My favorite numbers are: [22, 42, 73].");
 }

Modified: sandbox/explore/libs/explore/test/c_array.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/c_array.cpp (original)
+++ sandbox/explore/libs/explore/test/c_array.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,31 +9,30 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <string>
-#include <sstream>
 #include <vector>
 #include <boost/explore.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( basic_c_array_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_c_array_stream_test, C, test_types )
 {
     using namespace boost::explore;
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     int arri1[] = {1};
     str_out << arri1;
- BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1]");
 
- str_out.str("");
+ reset(str_out);
 
     int arri3[] = {1,2,3};
     str_out << arri3;
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2, 3]");
 }
 
-BOOST_AUTO_TEST_CASE( vector_in_c_array_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( vector_in_c_array_stream_test, C, test_types )
 {
     using namespace boost::explore;
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::vector<int> vi;
     vi.push_back(1);
@@ -42,26 +41,41 @@
 
     std::vector<int> arrvi1[] = {vi};
     str_out << arrvi1;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     std::vector<int> arrvi3[] = {vi,vi,vi};
     str_out << arrvi3;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
 }
 
 BOOST_AUTO_TEST_CASE( c_style_string_stream_test )
 {
     using namespace boost::explore;
- std::stringstream str_out;
+ test_traits<char>::stream_type str_out;
     
- const char s[4] = "abc";
+ const char s[4] = "abc";
     str_out << s;
- BOOST_CHECK_EQUAL(str_out.str(), "abc");
+ BOOST_CHECK_EQUAL(output(str_out), "abc");
     
- str_out.str("");
+ reset(str_out);
      
     str_out << "def";
- BOOST_CHECK_EQUAL(str_out.str(), "def");
+ BOOST_CHECK_EQUAL(output(str_out), "def");
+}
+
+BOOST_AUTO_TEST_CASE( c_style_wstring_stream_test )
+{
+ using namespace boost::explore;
+ test_traits<wchar_t>::stream_type str_out;
+
+ std::wstring s = L"abc";
+ str_out << s;
+ BOOST_CHECK_EQUAL(output(str_out), "abc");
+
+ reset(str_out);
+
+ str_out << std::wstring(L"def");
+ BOOST_CHECK_EQUAL(output(str_out), "def");
 }
\ No newline at end of file

Modified: sandbox/explore/libs/explore/test/columnated.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/columnated.cpp (original)
+++ sandbox/explore/libs/explore/test/columnated.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,30 +9,30 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <string>
-#include <sstream>
 #include <vector>
 #include <boost/explore.hpp>
+#include "boost_explore_test_tools.hpp"
 
+template<typename C>
 struct columnated_format
 {
     columnated_format(std::size_t rows, std::size_t width) : m_rows(rows), m_width(width) {}
     std::size_t m_rows;
     std::size_t m_width;
 
- friend std::ostream& operator<<(std::ostream& ostr, const columnated_format& f)
+ friend std::basic_ostream<C>& operator<<(std::basic_ostream<C>& ostr, const columnated_format<C>& f)
     {
         using namespace boost::explore;
         ostr << setrows(f.m_rows) << setitemwidth(f.m_width)
- << separator("") << start("") << boost::explore::end("");
+ << separator(str_to<C>("")) << start(str_to<C>("")) << boost::explore::end(str_to<C>(""));
         return ostr;
     }
 };
 
-BOOST_AUTO_TEST_CASE( basic_columnate_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_columnate_stream_test, C, test_types )
 {
     using namespace boost::explore;
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
     std::vector<int> vi;
 
     for( int i = 0; i < 12; ++i )
@@ -40,29 +40,29 @@
         vi.push_back(i);
     }
 
- str_out << setrows(3) << start("") << boost::explore::end("") << vi;
+ str_out << setrows(3) << start(str_to<C>("")) << boost::explore::end(str_to<C>("")) << vi;
 
- BOOST_CHECK_EQUAL(str_out.str(),
+ BOOST_CHECK_EQUAL(output(str_out),
         "0, 1, 2, \n"
         "3, 4, 5, \n"
         "6, 7, 8, \n"
         "9, 10, 11");
 
- str_out.str("");
+ reset(str_out);
 
- str_out << setrows(3) << setitemwidth(5) << start("") << boost::explore::end("") << vi;
+ str_out << setrows(3) << setitemwidth(5) << start(str_to<C>("")) << boost::explore::end(str_to<C>("")) << vi;
 
- BOOST_CHECK_EQUAL(str_out.str(),
+ BOOST_CHECK_EQUAL(output(str_out),
         " 0, 1, 2, \n"
         " 3, 4, 5, \n"
         " 6, 7, 8, \n"
         " 9, 10, 11");
 
- str_out.str("");
+ reset(str_out);
 
- str_out << columnated_format(3, 5) << vi;
+ str_out << columnated_format<C>(3, 5) << vi;
 
- BOOST_CHECK_EQUAL(str_out.str(),
+ BOOST_CHECK_EQUAL(output(str_out),
         " 0 1 2\n"
         " 3 4 5\n"
         " 6 7 8\n"

Modified: sandbox/explore/libs/explore/test/custom_format_simple.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/custom_format_simple.cpp (original)
+++ sandbox/explore/libs/explore/test/custom_format_simple.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -14,99 +14,106 @@
 #include <boost/explore/vector.hpp>
 #include <boost/explore/map.hpp>
 #include <boost/explore/iterator_range.hpp>
-#include <string>
-#include <sstream>
 #include <vector>
+#include "boost_explore_test_tools.hpp"
 
 std::ostream& basic_stream_format(std::ostream& ostr)
 {
     using namespace boost::explore;
     return ostr << start("<=") << separator("#") << end("=>")
- << assoc_start("<=") << assoc_separator("#") << assoc_end("=>");
+ << assoc_start("<=") << assoc_separator("#") << assoc_end("=>");
 }
 
-BOOST_AUTO_TEST_CASE( basic_vector_custom_format_stream_test )
+std::wostream& basic_stream_format(std::wostream& ostr)
 {
- std::stringstream str_out;
+ using namespace boost::explore;
+ return ostr << start(L"<=") << separator(L"#") << end(L"=>")
+ << assoc_start(L"<=") << assoc_separator(L"#") << assoc_end(L"=>");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_vector_custom_format_stream_test, C, test_types )
+{
+ test_traits<C>::stream_type str_out;
     str_out << basic_stream_format;
 
     std::vector<int> vi;
     str_out << vi;
- BOOST_CHECK_EQUAL(str_out.str(), "<==>");
+ BOOST_CHECK_EQUAL(output(str_out), "<==>");
 
- str_out.str("");
+ reset(str_out);
 
     vi.push_back(1);
     str_out << vi;
- BOOST_CHECK_EQUAL(str_out.str(), "<=1=>");
+ BOOST_CHECK_EQUAL(output(str_out), "<=1=>");
 
- str_out.str("");
+ reset(str_out);
 
     vi.push_back(2);
     vi.push_back(3);
     str_out << vi;
- BOOST_CHECK_EQUAL(str_out.str(), "<=1#2#3=>");
+ BOOST_CHECK_EQUAL(output(str_out), "<=1#2#3=>");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(vi.begin(), ++(++vi.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "<=1#2=>");
+ BOOST_CHECK_EQUAL(output(str_out), "<=1#2=>");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << vi;
- BOOST_CHECK_EQUAL(str_out.str(), "<=1#2#3=>");
+ BOOST_CHECK_EQUAL(output(str_out), "<=1#2#3=>");
 }
 
-BOOST_AUTO_TEST_CASE( basic_map_custom_format_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_map_custom_format_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ typedef test_traits<C>::string_type string_type;
+ test_traits<C>::stream_type str_out;
     str_out << basic_stream_format;
 
- std::map<int,std::string> mis;
+ std::map<int, string_type> mis;
     str_out << mis;
- BOOST_CHECK_EQUAL(str_out.str(), "<==>");
+ BOOST_CHECK_EQUAL(output(str_out), "<==>");
 
- str_out.str("");
+ reset(str_out);
 
- mis.insert(std::make_pair(1, "first"));
+ mis.insert(std::make_pair(1, str_to<C>("first")));
     str_out << mis;
- BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>=>");
+ BOOST_CHECK_EQUAL(output(str_out), "<=<=1#first=>=>");
 
- str_out.str("");
+ reset(str_out);
 
- mis.insert(std::make_pair(2, "second"));
- mis.insert(std::make_pair(3, "third"));
+ mis.insert(std::make_pair(2, str_to<C>("second")));
+ mis.insert(std::make_pair(3, str_to<C>("third")));
 
     str_out << mis;
- BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>#<=3#third=>=>");
+ BOOST_CHECK_EQUAL(output(str_out), "<=<=1#first=>#<=2#second=>#<=3#third=>=>");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(mis.begin(), ++(++mis.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>=>");
+ BOOST_CHECK_EQUAL(output(str_out), "<=<=1#first=>#<=2#second=>=>");
 }
 
-BOOST_AUTO_TEST_CASE( begin_end_helper_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( begin_end_helper_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
     
     std::vector<int> vi;
     vi.push_back(1);
     vi.push_back(2);
     vi.push_back(3);
- str_out << boost::explore::begin_end("B ", " E") << vi;
- BOOST_CHECK_EQUAL(str_out.str(), "B 1, 2, 3 E");
+ str_out << boost::explore::begin_end(str_to<C>("B "), str_to<C>(" E")) << vi;
+ BOOST_CHECK_EQUAL(output(str_out), "B 1, 2, 3 E");
 }
 
-BOOST_AUTO_TEST_CASE( delimeters_helper_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( delimeters_helper_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
     
     std::vector<int> vi;
     vi.push_back(1);
     vi.push_back(2);
     vi.push_back(3);
- str_out << boost::explore::delimiters("F ", " - ", " L") << vi;
- BOOST_CHECK_EQUAL(str_out.str(), "F 1 - 2 - 3 L");
+ str_out << boost::explore::delimiters(str_to<C>("F "), str_to<C>(" - "), str_to<C>(" L")) << vi;
+ BOOST_CHECK_EQUAL(output(str_out), "F 1 - 2 - 3 L");
 }

Modified: sandbox/explore/libs/explore/test/html_table_output.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/html_table_output.cpp (original)
+++ sandbox/explore/libs/explore/test/html_table_output.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -10,10 +10,9 @@
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
 #include <boost/explore/manipulators.hpp>
-#include <string>
-#include <sstream>
 #include <vector>
 #include <boost/explore.hpp>
+#include "boost_explore_test_tools.hpp"
 
 std::ostream& html_table_stream_format(std::ostream& ostr)
 {
@@ -31,10 +30,26 @@
     return ostr;
 }
 
-BOOST_AUTO_TEST_CASE( vector_in_c_array_html_stream_test )
+std::wostream& html_table_stream_format(std::wostream& ostr)
 {
     using namespace boost::explore;
- std::stringstream str_out;
+ ostr << level(0);
+ ostr << start(L"<table>\n")
+ << separator(L"")
+ << boost::explore::end(L"</table>\n");
+
+ ostr << level(1);
+ ostr << start(L"<tr><td>")
+ << separator(L"</td><td>")
+ << boost::explore::end(L"</td></tr>\n");
+
+ return ostr;
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( vector_in_c_array_html_stream_test, C, test_types )
+{
+ using namespace boost::explore;
+ test_traits<C>::stream_type str_out;
     str_out << html_table_stream_format;
 
     std::vector<int> vi;
@@ -45,16 +60,16 @@
     std::vector<int> arrvi1[] = {vi};
     str_out << arrvi1;
 
- BOOST_CHECK_EQUAL(str_out.str(),
+ BOOST_CHECK_EQUAL(output(str_out),
         "<table>\n"
         "<tr><td>1</td><td>2</td><td>3</td></tr>\n"
         "</table>\n");
 
- str_out.str("");
+ reset(str_out);
 
     std::vector<int> arrvi3[] = {vi,vi,vi};
     str_out << arrvi3;
- BOOST_CHECK_EQUAL(str_out.str(),
+ BOOST_CHECK_EQUAL(output(str_out),
         "<table>\n"
         "<tr><td>1</td><td>2</td><td>3</td></tr>\n"
         "<tr><td>1</td><td>2</td><td>3</td></tr>\n"

Modified: sandbox/explore/libs/explore/test/is_assoc_iter.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/is_assoc_iter.cpp (original)
+++ sandbox/explore/libs/explore/test/is_assoc_iter.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,14 +9,13 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <sstream>
-#include <vector>
 #include <map>
 #include <list>
 #include <boost/explore.hpp>
 #include <boost/explore/is_assoc_iter.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( is_assoc_iter_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( is_assoc_iter_test, C, test_types )
 {
     bool mapHasAssocIter = boost::explore::is_assoc_iter<std::map<int, double>::iterator>::type();
     BOOST_CHECK(mapHasAssocIter);

Modified: sandbox/explore/libs/explore/test/multi_dim_test.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/multi_dim_test.cpp (original)
+++ sandbox/explore/libs/explore/test/multi_dim_test.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,10 +9,9 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <string>
-#include <sstream>
 #include <vector>
 #include <boost/explore.hpp>
+#include "boost_explore_test_tools.hpp"
 
 std::ostream& format_2d(std::ostream& ostr)
 {
@@ -27,9 +26,22 @@
     return ostr;
 }
 
-BOOST_AUTO_TEST_CASE( two_dimension_stream_test )
+std::wostream& format_2d(std::wostream& ostr)
 {
- std::stringstream str_out;
+ using namespace boost::explore;
+
+ ostr << level(0);
+ ostr << start(L"") << boost::explore::end(L"") << separator(L"\n");
+
+ ostr << level(1);
+ ostr << start(L"|") << boost::explore::end(L"|") << separator(L" ");
+
+ return ostr;
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( two_dimension_stream_test, C, test_types )
+{
+ test_traits<C>::stream_type str_out;
 
     std::vector<int> vi;
     std::vector<std::vector<int> > vvi;
@@ -43,7 +55,7 @@
     vvi.push_back(vi);
 
     str_out << format_2d << vvi;
- BOOST_CHECK_EQUAL(str_out.str(),
+ BOOST_CHECK_EQUAL(output(str_out),
         "|1 2 3|\n"
         "|1 2 3|\n"
         "|1 2 3|");
@@ -65,9 +77,25 @@
     return ostr;
 }
 
-BOOST_AUTO_TEST_CASE( three_dimension_stream_test )
+std::wostream& format_3d(std::wostream& ostr)
+{
+ using namespace boost::explore;
+
+ ostr << level(0);
+ ostr << start(L"") << boost::explore::end(L"") << separator(L"\n\n");
+
+ ostr << level(1);
+ ostr << start(L"") << boost::explore::end(L"") << separator(L"\n");
+
+ ostr << level(2);
+ ostr << start(L"|") << boost::explore::end(L"|") << separator(L" ");
+
+ return ostr;
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( three_dimension_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::vector<int> vi;
     std::vector<std::vector<int> > vvi;
@@ -86,7 +114,7 @@
     vvvi.push_back(vvi);
 
     str_out << format_3d << vvvi;
- BOOST_CHECK_EQUAL(str_out.str(),
+ BOOST_CHECK_EQUAL(output(str_out),
         "|1 2 3|\n"
         "|1 2 3|\n"
         "|1 2 3|\n"

Modified: sandbox/explore/libs/explore/test/simple_types.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/simple_types.cpp (original)
+++ sandbox/explore/libs/explore/test/simple_types.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,21 +9,20 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <string>
-#include <sstream>
 #include <iomanip>
 #include <boost/lexical_cast.hpp>
 #include <boost/explore.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( int_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( int_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
     int i = 123;
 
     str_out << i;
- BOOST_CHECK_EQUAL(str_out.str(), "123");
+ BOOST_CHECK_EQUAL(output(str_out), "123");
 
- str_out.str("");
+ reset(str_out);
     int* pi = &i;
 
     str_out << pi;
@@ -31,69 +30,79 @@
     // it is highly unlikely to be false. Otherwise this test is only
     // telling you whether the following is even valid.
     //BOOST_CHECK(0 != boost::lexical_cast<std::string>((long)pi).compare("123"));
- //BOOST_CHECK_EQUAL(str_out.str(), "123");
+ //BOOST_CHECK_EQUAL(output(str_out), "123");
 }
 
-BOOST_AUTO_TEST_CASE( float_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( float_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
     float f = 1.234f;
 
     str_out << std::setprecision(4) << f;
- BOOST_CHECK_EQUAL(str_out.str(), "1.234");
+ BOOST_CHECK_EQUAL(output(str_out), "1.234");
 
     //BOOST_CHECK_MESSAGE(false, "Test min precision");
     //BOOST_CHECK_MESSAGE(false, "Test max precision");
 }
 
-BOOST_AUTO_TEST_CASE( double_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( double_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
     double d = 1.2341234f;
 
     str_out << std::setprecision(7) << d;
- BOOST_CHECK_EQUAL(str_out.str(), "1.234123");
+ BOOST_CHECK_EQUAL(output(str_out), "1.234123");
 
     //BOOST_CHECK_MESSAGE(false, "Test min precision");
     //BOOST_CHECK_MESSAGE(false, "Test max precision");
 }
 
-BOOST_AUTO_TEST_CASE( bool_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( bool_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
     bool b = true;
 
     str_out << std::boolalpha << b;
- BOOST_CHECK_EQUAL(str_out.str(), "true");
+ BOOST_CHECK_EQUAL(output(str_out), "true");
 
- str_out.str("");
+ reset(str_out);
     b = false;
 
     str_out << std::boolalpha << b;
- BOOST_CHECK_EQUAL(str_out.str(), "false");
+ BOOST_CHECK_EQUAL(output(str_out), "false");
 }
 
-BOOST_AUTO_TEST_CASE( char_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( char_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
     char c = 'c';
 
     str_out << c;
- BOOST_CHECK_EQUAL(str_out.str(), "c");
+ BOOST_CHECK_EQUAL(output(str_out), "c");
 
- str_out.str("");
+ reset(str_out);
     char* pc = "c";
 
     str_out << pc;
- BOOST_CHECK_EQUAL(str_out.str(), "c");
+ BOOST_CHECK_EQUAL(output(str_out), "c");
 }
 
 BOOST_AUTO_TEST_CASE( string_stream_test )
 {
- std::stringstream str_out;
+ test_traits<char>::stream_type str_out;
     std::string s = "some string";
 
     str_out << s;
 
- BOOST_CHECK_EQUAL(str_out.str(), "some string");
+ BOOST_CHECK_EQUAL(output(str_out), "some string");
+}
+
+BOOST_AUTO_TEST_CASE( wstring_stream_test )
+{
+ test_traits<wchar_t>::stream_type str_out;
+ std::wstring s = L"some string";
+
+ str_out << s;
+
+ BOOST_CHECK_EQUAL(output(str_out), "some string");
 }

Modified: sandbox/explore/libs/explore/test/std_deque.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/std_deque.cpp (original)
+++ sandbox/explore/libs/explore/test/std_deque.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,41 +9,40 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <string>
-#include <sstream>
 #include <boost/explore/deque.hpp>
 #include <boost/explore/iterator_range.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( basic_deque_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_deque_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::deque<int> di;
     str_out << di;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     di.push_back(1);
     str_out << di;
- BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1]");
 
- str_out.str("");
+ reset(str_out);
 
     di.push_back(2);
     di.push_back(3);
     str_out << di;
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2, 3]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(di.begin(), ++(++di.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2]");
 }
 
-BOOST_AUTO_TEST_CASE( deque_in_deque_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( deque_in_deque_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::deque<int> di;
     di.push_back(1);
@@ -52,23 +51,23 @@
 
     std::deque<std::deque<int> > ddi;
     str_out << ddi;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     ddi.push_back(di);
     str_out << ddi;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     ddi.push_back(di);
     ddi.push_back(di);
     str_out << ddi;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(ddi.begin(), ++(++ddi.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3]]");
 }

Modified: sandbox/explore/libs/explore/test/std_list.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/std_list.cpp (original)
+++ sandbox/explore/libs/explore/test/std_list.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,42 +9,41 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <string>
-#include <sstream>
 #include <complex>
 #include <boost/explore/list.hpp>
 #include <boost/explore/iterator_range.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( basic_list_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_list_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::list<std::complex<double> > lc;
     str_out << lc;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     lc.push_back(std::complex<double>(0,1));
     str_out << lc;
- BOOST_CHECK_EQUAL(str_out.str(), "[(0,1)]");
+ BOOST_CHECK_EQUAL(output(str_out), "[(0,1)]");
 
- str_out.str("");
+ reset(str_out);
 
     lc.push_back(std::complex<double>(2,3));
     lc.push_back(std::complex<double>(4,5));
     str_out << lc;
- BOOST_CHECK_EQUAL(str_out.str(), "[(0,1), (2,3), (4,5)]");
+ BOOST_CHECK_EQUAL(output(str_out), "[(0,1), (2,3), (4,5)]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(lc.begin(), ++(++lc.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[(0,1), (2,3)]");
+ BOOST_CHECK_EQUAL(output(str_out), "[(0,1), (2,3)]");
 }
 
-BOOST_AUTO_TEST_CASE( list_in_list_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( list_in_list_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::list<int> li;
     li.push_back(1);
@@ -53,23 +52,23 @@
 
     std::list<std::list<int> > lli;
     str_out << lli;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     lli.push_back(li);
     str_out << lli;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     lli.push_back(li);
     lli.push_back(li);
     str_out << lli;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(lli.begin(), ++(++lli.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3]]");
 }

Modified: sandbox/explore/libs/explore/test/std_map.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/std_map.cpp (original)
+++ sandbox/explore/libs/explore/test/std_map.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,77 +9,76 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <string>
-#include <sstream>
 #include <vector>
 #include <boost/explore/map.hpp>
 #include <boost/explore/vector.hpp>
 #include <boost/explore/iterator_range.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( basic_map_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_map_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
- std::map<int,std::string> mis;
+ std::map<int, test_traits<C>::string_type> mis;
     str_out << mis;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
- mis.insert(std::make_pair(1, "first"));
+ mis.insert(std::make_pair(1, str_to<C>("first")));
     str_out << mis;
- BOOST_CHECK_EQUAL(str_out.str(), "[1:first]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1:first]");
 
- str_out.str("");
+ reset(str_out);
 
- mis.insert(std::make_pair(2, "second"));
- mis.insert(std::make_pair(3, "third"));
+ mis.insert(std::make_pair(2, str_to<C>("second")));
+ mis.insert(std::make_pair(3, str_to<C>("third")));
     str_out << mis;
- BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 2:second, 3:third]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1:first, 2:second, 3:third]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(mis.begin(), ++(++mis.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 2:second]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1:first, 2:second]");
 }
 
-BOOST_AUTO_TEST_CASE( basic_multimap_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_multimap_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
- std::multimap<int,std::string> mmis;
+ std::multimap<int, test_traits<C>::string_type> mmis;
     str_out << mmis;;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
- mmis.insert(std::make_pair(1, "first"));
+ mmis.insert(std::make_pair(1, str_to<C>("first")));
     str_out << mmis;
- BOOST_CHECK_EQUAL(str_out.str(), "[1:first]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1:first]");
 
- str_out.str("");
+ reset(str_out);
 
- mmis.insert(std::make_pair(1, "single"));
+ mmis.insert(std::make_pair(1, str_to<C>("single")));
     str_out << mmis;
- BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 1:single]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1:first, 1:single]");
 
- str_out.str("");
+ reset(str_out);
 
- mmis.insert(std::make_pair(2, "second"));
- mmis.insert(std::make_pair(3, "third"));
- mmis.insert(std::make_pair(3, "triple"));
+ mmis.insert(std::make_pair(2, str_to<C>("second")));
+ mmis.insert(std::make_pair(3, str_to<C>("third")));
+ mmis.insert(std::make_pair(3, str_to<C>("triple")));
     str_out << mmis;
- BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 1:single, 2:second, 3:third, 3:triple]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1:first, 1:single, 2:second, 3:third, 3:triple]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(mmis.begin(), ++(++mmis.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 1:single]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1:first, 1:single]");
 }
 
-BOOST_AUTO_TEST_CASE( vector_in_map_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( vector_in_map_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::vector<int> vi;
     vi.push_back(1);
@@ -88,23 +87,23 @@
 
     std::map<int,std::vector<int> > mivi;
     str_out << mivi;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     mivi.insert(std::make_pair(1, vi));
     str_out << mivi;
- BOOST_CHECK_EQUAL(str_out.str(), "[1:[1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1:[1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     mivi.insert(std::make_pair(2, vi));
     mivi.insert(std::make_pair(3, vi));
     str_out << mivi;
- BOOST_CHECK_EQUAL(str_out.str(), "[1:[1, 2, 3], 2:[1, 2, 3], 3:[1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1:[1, 2, 3], 2:[1, 2, 3], 3:[1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(mivi.begin(), ++(++mivi.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[1:[1, 2, 3], 2:[1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1:[1, 2, 3], 2:[1, 2, 3]]");
 }

Modified: sandbox/explore/libs/explore/test/std_pair.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/std_pair.cpp (original)
+++ sandbox/explore/libs/explore/test/std_pair.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,46 +9,45 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <sstream>
-#include <vector>
 #include <boost/explore/pair.hpp>
 #include <boost/explore/vector.hpp>
 #include <boost/explore/iterator_range.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( basic_pair_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_pair_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::pair<int,int> pi = std::make_pair(1,2);
     str_out << pi;
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2]");
 }
 
-BOOST_AUTO_TEST_CASE( pair_in_vector_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( pair_in_vector_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::vector<std::pair<int,int> > vpi;
     str_out << vpi;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     std::pair<int,int> pi = std::make_pair(1,2);
 
     vpi.push_back(pi);
     str_out << vpi;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2]]");
 
- str_out.str("");
+ reset(str_out);
 
     vpi.push_back(pi);
     vpi.push_back(pi);
     str_out << vpi;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2], [1, 2], [1, 2]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2], [1, 2], [1, 2]]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(vpi.begin(), ++(++vpi.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2], [1, 2]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2], [1, 2]]");
 }

Modified: sandbox/explore/libs/explore/test/std_set.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/std_set.cpp (original)
+++ sandbox/explore/libs/explore/test/std_set.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,79 +9,77 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <string>
-#include <sstream>
 #include <vector>
 #include <boost/explore/set.hpp>
 #include <boost/explore/vector.hpp>
 #include <boost/explore/iterator_range.hpp>
-
 #include <boost/explore.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( basic_set_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_set_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::set<int> si;
     str_out << si;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     si.insert(1);
     str_out << si;
- BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1]");
 
- str_out.str("");
+ reset(str_out);
 
     si.insert(2);
     si.insert(3);
     str_out << si;
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2, 3]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(si.begin(), ++(++si.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2]");
 }
 
-BOOST_AUTO_TEST_CASE( basic_multiset_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_multiset_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::multiset<int> msi;
     str_out << msi;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     msi.insert(1);
     str_out << msi;
- BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1]");
 
- str_out.str("");
+ reset(str_out);
 
     msi.insert(1);
     str_out << msi;
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 1]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 1]");
 
- str_out.str("");
+ reset(str_out);
 
     msi.insert(2);
     msi.insert(3);
     msi.insert(3);
     str_out << msi;
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 1, 2, 3, 3]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 1, 2, 3, 3]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(msi.begin(), ++(++msi.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 1]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 1]");
 }
 
-BOOST_AUTO_TEST_CASE( vector_in_set_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( vector_in_set_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::vector<int> vi;
     vi.push_back(1);
@@ -90,23 +88,23 @@
 
     std::multiset<std::vector<int> > svi;
     str_out << svi;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     svi.insert(vi);
     str_out << svi;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     svi.insert(vi);
     svi.insert(vi);
     str_out << svi;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(svi.begin(), ++(++svi.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3]]");
 }

Modified: sandbox/explore/libs/explore/test/std_vector.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/std_vector.cpp (original)
+++ sandbox/explore/libs/explore/test/std_vector.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,41 +9,40 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <string>
-#include <sstream>
 #include <boost/explore/iterator_range.hpp>
 #include <boost/explore/vector.hpp>
+#include "boost_explore_test_tools.hpp"
 
-BOOST_AUTO_TEST_CASE( basic_vector_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( basic_vector_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::vector<int> vi;
     str_out << vi;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     vi.push_back(1);
     str_out << vi;
- BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1]");
 
- str_out.str("");
+ reset(str_out);
 
     vi.push_back(2);
     vi.push_back(3);
     str_out << vi;
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2, 3]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(vi.begin(), ++(++vi.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2]");
 }
 
-BOOST_AUTO_TEST_CASE( vector_in_vector_stream_test )
+BOOST_AUTO_TEST_CASE_TEMPLATE( vector_in_vector_stream_test, C, test_types )
 {
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     std::vector<int> vi;
     vi.push_back(1);
@@ -52,33 +51,43 @@
 
     std::vector<std::vector<int> > vvi;
     str_out << vvi;
- BOOST_CHECK_EQUAL(str_out.str(), "[]");
+ BOOST_CHECK_EQUAL(output(str_out), "[]");
 
- str_out.str("");
+ reset(str_out);
 
     vvi.push_back(vi);
     str_out << vvi;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     vvi.push_back(vi);
     vvi.push_back(vi);
     str_out << vvi;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
 
- str_out.str("");
+ reset(str_out);
 
     str_out << boost::explore::make_iterator_range(vvi.begin(), ++(++vvi.begin()));
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3]]");
 }
 
 BOOST_AUTO_TEST_CASE( vector_with_ugly_string_case_stream_test )
 {
- std::stringstream str_out;
+ test_traits<char>::stream_type str_out;
 
     std::vector<std::string> vs;
     vs.push_back("[1, 2, 3], [1, 2, 3], [1, 2, 3]");
     str_out << vs;
- BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_with_ugly_wstring_case_stream_test )
+{
+ test_traits<wchar_t>::stream_type str_out;
+
+ std::vector<std::wstring> vs;
+ vs.push_back(L"[1, 2, 3], [1, 2, 3], [1, 2, 3]");
+ str_out << vs;
+ BOOST_CHECK_EQUAL(output(str_out), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
 }

Modified: sandbox/explore/libs/explore/test/user_defined_container.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/user_defined_container.cpp (original)
+++ sandbox/explore/libs/explore/test/user_defined_container.cpp 2009-08-30 18:16:39 EDT (Sun, 30 Aug 2009)
@@ -9,10 +9,10 @@
 
 #define BOOST_TEST_MODULE PrintLib
 #include <boost/test/unit_test.hpp>
-#include <sstream>
 #include <vector>
 #include <boost/assign.hpp>
 #include <boost/explore.hpp>
+#include "boost_explore_test_tools.hpp"
 
 class user_vector
 {
@@ -42,13 +42,18 @@
     return boost::explore::stream_container(ostr, u.start(), u.finish());
 }
 
-BOOST_AUTO_TEST_CASE( user_defined_stream_test )
+std::wostream& operator<<(std::wostream& ostr, const user_vector& u)
 {
- std::stringstream str_out;
+ return boost::explore::stream_container(ostr, u.start(), u.finish());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( user_defined_stream_test, C, test_types )
+{
+ test_traits<C>::stream_type str_out;
 
     user_vector v;
     str_out << v;
- BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+ BOOST_CHECK_EQUAL(output(str_out), "[1, 2, 3]");
 }
 
 class my_container
@@ -61,6 +66,7 @@
     }
 
     friend std::ostream& operator<<(std::ostream& ostr, const my_container& c);
+ friend std::wostream& operator<<(std::wostream& ostr, const my_container& c);
 
 private:
     std::vector<int> m_data;
@@ -72,33 +78,40 @@
     return ostr << custom() << delimiters("/", "::", "/") << c.m_data;
 }
 
-BOOST_AUTO_TEST_CASE( custom_stream_test )
+std::wostream& operator<<(std::wostream& ostr, const my_container& c)
+{
+ using namespace boost::explore;
+ return ostr << custom() << delimiters(L"/", L"::", L"/") << c.m_data;
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( custom_stream_test, C, test_types )
 {
     using namespace boost::assign;
     using namespace boost::explore;
- std::stringstream str_out;
+ test_traits<C>::stream_type str_out;
 
     my_container mc;
     str_out << mc;
- BOOST_CHECK_EQUAL(str_out.str(), "/1::2::3::4::5::6/");
+ BOOST_CHECK_EQUAL(output(str_out), "/1::2::3::4::5::6/");
 
- str_out.str("");
+ reset(str_out);
 
     std::vector<my_container> vmc;
     vmc += mc, mc;
- str_out << delimiters("{\n ", "\n ", "\n}") << vmc;
- BOOST_CHECK_EQUAL(str_out.str(),
+ str_out << delimiters("{\n ", "\n ", "\n}") << delimiters(L"{\n ", L"\n ", L"\n}") ;
+ str_out << vmc;
+ BOOST_CHECK_EQUAL(output(str_out),
         "{\n"
         " /1::2::3::4::5::6/\n"
         " /1::2::3::4::5::6/\n"
         "}");
 
- str_out.str("");
+ reset(str_out);
 
     std::vector<std::vector<my_container> > vvmc;
     vvmc += vmc, vmc;
- str_out << level(1) << delimiters("[", " xxx ", "]") << vvmc;
- BOOST_CHECK_EQUAL(str_out.str(),
+ str_out << level(1) << delimiters("[", " xxx ", "]") << delimiters(L"[", L" xxx ", L"]") << vvmc;
+ BOOST_CHECK_EQUAL(output(str_out),
         "{\n"
         " [/1::2::3::4::5::6/ xxx /1::2::3::4::5::6/]\n"
         " [/1::2::3::4::5::6/ xxx /1::2::3::4::5::6/]\n"


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