Boost logo

Boost-Commit :

From: jeff_at_[hidden]
Date: 2008-03-23 18:56:41


Author: jefffaust
Date: 2008-03-23 18:56:41 EDT (Sun, 23 Mar 2008)
New Revision: 43811
URL: http://svn.boost.org/trac/boost/changeset/43811

Log:
add vector<variant> test

Text files modified:
   sandbox/explore/libs/explore/test/boost_variant.cpp | 31 +++++++++++++++++++++++++++++++
   1 files changed, 31 insertions(+), 0 deletions(-)

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 2008-03-23 18:56:41 EDT (Sun, 23 Mar 2008)
@@ -40,3 +40,34 @@
     str_out << varVal;
     BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
 }
+
+BOOST_AUTO_TEST_CASE( cool_variant_stream_test )
+{
+ using namespace explore;
+ std::stringstream str_out;
+
+ 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(".");
+
+ // level 0
+ str_out << start("") << explore::end("") << separator("");
+
+ // level 1 (for nested collection)
+ str_out << start("[", 1) << explore::end("]", 1) << separator(", ", 1);
+
+ 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].");
+}


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