Boost logo

Boost-Commit :

From: jefffaust_at_[hidden]
Date: 2007-05-27 18:15:00


Author: jefffaust
Date: 2007-05-27 18:14:58 EDT (Sun, 27 May 2007)
New Revision: 4319
URL: http://svn.boost.org/trac/boost/changeset/4319

Log:
Add streaming version of custom format tests (sans iterator test)

Text files modified:
   sandbox/explore/libs/explore/test/basic_lg_format.hpp | 8 ++
   sandbox/explore/libs/explore/test/custom_format_simple.cpp | 112 ++++++++++++++++++++++++++++++++-------
   2 files changed, 100 insertions(+), 20 deletions(-)

Modified: sandbox/explore/libs/explore/test/basic_lg_format.hpp
==============================================================================
--- sandbox/explore/libs/explore/test/basic_lg_format.hpp (original)
+++ sandbox/explore/libs/explore/test/basic_lg_format.hpp 2007-05-27 18:14:58 EDT (Sun, 27 May 2007)
@@ -30,3 +30,11 @@
 
 
 struct basic_lg_format : boost::mpl::list< basic_lg_range_format_selector> {};
+
+// for streaming
+std::ostream& basic_lg_stream_format(std::ostream& ostr)
+{
+ using namespace explore;
+ return ostr << setStart("<=") << setSeparator("#") << setEnd("=>")
+ << setAssocStart("<=") << setAssocSeparator("#") << setAssocEnd("=>");
+}

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 2007-05-27 18:14:58 EDT (Sun, 27 May 2007)
@@ -20,68 +20,140 @@
 BOOST_AUTO_TEST_CASE( basic_vector_custom_format_print_test )
 {
     std::stringstream str_out;
-
+
     std::vector<int> vi;
     explore::print(vi, str_out, basic_lg_format(), explore::default_container_policy());
     BOOST_CHECK_EQUAL(str_out.str(), "<==>");
-
+
     str_out.str("");
-
+
     vi.push_back(1);
     explore::print(vi, str_out, basic_lg_format(), explore::default_container_policy());
     BOOST_CHECK_EQUAL(str_out.str(), "<=1=>");
-
+
     str_out.str("");
-
+
     vi.push_back(2);
     vi.push_back(3);
     explore::print(vi, str_out, basic_lg_format(), explore::default_container_policy());
     BOOST_CHECK_EQUAL(str_out.str(), "<=1#2#3=>");
-
+
     str_out.str("");
-
+
     explore::print(vi.begin(), ++(++vi.begin()), str_out, basic_lg_format(), explore::default_container_policy());
     BOOST_CHECK_EQUAL(str_out.str(), "<=1#2=>");
-
+
     str_out.str("");
-
+
     explore::print(boost::make_iterator_range(vi.begin(), ++(++vi.begin())), str_out, basic_lg_format(), explore::default_container_policy());
     BOOST_CHECK_EQUAL(str_out.str(), "<=1#2=>");
-
+
     str_out.str("");
-
+
     explore::print(vi, str_out, basic_lg_format(), explore::default_container_policy());
     BOOST_CHECK_EQUAL(str_out.str(), "<=1#2#3=>");
 }
 
+BOOST_AUTO_TEST_CASE( basic_vector_custom_format_stream_test )
+{
+ std::stringstream str_out;
+ str_out << basic_lg_stream_format;
+
+ std::vector<int> vi;
+ str_out << vi;
+ BOOST_CHECK_EQUAL(str_out.str(), "<==>");
+
+ str_out.str("");
+
+ vi.push_back(1);
+ str_out << vi;
+ BOOST_CHECK_EQUAL(str_out.str(), "<=1=>");
+
+ str_out.str("");
+
+ vi.push_back(2);
+ vi.push_back(3);
+ str_out << vi;
+ BOOST_CHECK_EQUAL(str_out.str(), "<=1#2#3=>");
+
+ //str_out.str("");
+
+ //explore::print(vi.begin(), ++(++vi.begin()), str_out, basic_lg_format(), explore::default_container_policy());
+ //BOOST_CHECK_EQUAL(str_out.str(), "<=1#2=>");
+
+ //str_out.str("");
+
+ //explore::print(boost::make_iterator_range(vi.begin(), ++(++vi.begin())), str_out, basic_lg_format(), explore::default_container_policy());
+ //BOOST_CHECK_EQUAL(str_out.str(), "<=1#2=>");
+
+ //str_out.str("");
+
+ //explore::print(vi, str_out, basic_lg_format(), explore::default_container_policy());
+ //BOOST_CHECK_EQUAL(str_out.str(), "<=1#2#3=>");
+}
+
 BOOST_AUTO_TEST_CASE( basic_map_custom_format_print_test )
 {
     std::stringstream str_out;
-
+
     std::map<int,std::string> mis;
     explore::print(mis, str_out, basic_lg_format(), explore::default_container_policy());
     BOOST_CHECK_EQUAL(str_out.str(), "<==>");
-
+
     str_out.str("");
-
+
     mis.insert(std::make_pair(1, "first"));
     explore::print(mis, str_out, basic_lg_format(), explore::default_container_policy());
     BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>=>");
-
+
     str_out.str("");
-
+
     mis.insert(std::make_pair(2, "second"));
     mis.insert(std::make_pair(3, "third"));
     explore::print(mis, str_out, basic_lg_format(), explore::default_container_policy());
     BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>#<=3#third=>=>");
-
+
     str_out.str("");
-
+
     explore::print(mis.begin(), ++(++mis.begin()), str_out, basic_lg_format(), explore::default_container_policy());
     BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>=>");
-
+
     str_out.str("");
-
+
     explore::print(boost::make_iterator_range(mis.begin(), ++(++mis.begin())), str_out, basic_lg_format(), explore::default_container_policy());
     BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>=>");
 }
+
+BOOST_AUTO_TEST_CASE( basic_map_custom_format_stream_test )
+{
+ std::stringstream str_out;
+ str_out << basic_lg_stream_format;
+
+ std::map<int,std::string> mis;
+ str_out << mis;
+ BOOST_CHECK_EQUAL(str_out.str(), "<==>");
+
+ str_out.str("");
+
+ mis.insert(std::make_pair(1, "first"));
+ str_out << mis;
+ BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>=>");
+
+ str_out.str("");
+
+ mis.insert(std::make_pair(2, "second"));
+ mis.insert(std::make_pair(3, "third"));
+
+ str_out << mis;
+ BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>#<=3#third=>=>");
+
+ //str_out.str("");
+
+ //explore::print(mis.begin(), ++(++mis.begin()), str_out, basic_lg_format(), explore::default_container_policy());
+ //BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>=>");
+
+ //str_out.str("");
+
+ //explore::print(boost::make_iterator_range(mis.begin(), ++(++mis.begin())), str_out, basic_lg_format(), explore::default_container_policy());
+ //BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>=>");
+}


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