$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r63119 - in trunk: boost/io boost/io/detail libs/io/doc libs/io/test
From: bdawes_at_[hidden]
Date: 2010-06-19 16:30:32
Author: bemandawes
Date: 2010-06-19 16:30:31 EDT (Sat, 19 Jun 2010)
New Revision: 63119
URL: http://svn.boost.org/trac/boost/changeset/63119
Log:
Add boost/io/detail/quoted_manip.hpp, with docs and test
Added:
   trunk/boost/io/detail/
      - copied from r63109, /branches/filesystem3/boost/io/detail/
   trunk/boost/io/detail/quoted_manip.hpp
      - copied, changed from r63109, /branches/filesystem3/boost/io/detail/quoted_manip.hpp
   trunk/libs/io/doc/quoted_manip.html
      - copied unchanged from r63109, /branches/filesystem3/libs/io/doc/quoted_manip.html
   trunk/libs/io/test/quoted_manip_test.cpp   (contents, props changed)
Properties modified: 
   trunk/boost/io/   (props changed)
   trunk/libs/io/doc/   (props changed)
Text files modified: 
   trunk/boost/io/detail/quoted_manip.hpp |     6 ++++--                                  
   trunk/libs/io/test/Jamfile.v2          |     2 ++                                      
   2 files changed, 6 insertions(+), 2 deletions(-)
Copied: trunk/boost/io/detail/quoted_manip.hpp (from r63109, /branches/filesystem3/boost/io/detail/quoted_manip.hpp)
==============================================================================
--- /branches/filesystem3/boost/io/detail/quoted_manip.hpp	(original)
+++ trunk/boost/io/detail/quoted_manip.hpp	2010-06-19 16:30:31 EDT (Sat, 19 Jun 2010)
@@ -66,8 +66,10 @@
         std::basic_string<Char, Traits, Alloc> const & string, Char escape, Char delim)
       {
         os << delim;
-        std::basic_string<Char, Traits, Alloc>::const_iterator end_it = string.end();
-        for (std::basic_string<Char, Traits, Alloc>::const_iterator it = string.begin();
+        typename std::basic_string<Char, Traits, Alloc>::const_iterator
+          end_it = string.end();
+        for (typename std::basic_string<Char, Traits, Alloc>::const_iterator
+          it = string.begin();
           it != end_it;
           ++it )
         {
Modified: trunk/libs/io/test/Jamfile.v2
==============================================================================
--- trunk/libs/io/test/Jamfile.v2	(original)
+++ trunk/libs/io/test/Jamfile.v2	2010-06-19 16:30:31 EDT (Sat, 19 Jun 2010)
@@ -21,4 +21,6 @@
               : # input files
               # : std::locale-support
         ]
+        
+        [ run quoted_manip_test.cpp ]
   ;
Added: trunk/libs/io/test/quoted_manip_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/io/test/quoted_manip_test.cpp	2010-06-19 16:30:31 EDT (Sat, 19 Jun 2010)
@@ -0,0 +1,92 @@
+//  libs/io/test/quote_manip_test.cpp  -----------------------------------------------  //
+
+//  Copyright Beman Dawes 2010
+
+//  Distributed under the Boost Software License, Version 1.0.
+//  See http://www.boost.org/LICENSE_1_0.txt
+
+//  Library home page: http://www.boost.org/libs/io
+
+//  ----------------------------------------------------------------------------------  //
+
+#include <boost/io/detail/quoted_manip.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+#include <sstream>
+
+using boost::io::quoted;
+using std::string;
+using std::wstring;
+
+int main()
+{
+
+  std::stringstream ss;
+  std::wstringstream wss;
+
+  const string s1("foo\\bar, \" *");
+  string r; // test results
+
+  ss << quoted(s1);
+  ss >> r;
+  BOOST_TEST_EQ(r, "\"foo\\\\bar, \\\" *\"");
+
+  ss << quoted(s1.c_str());
+  ss >> r;
+  BOOST_TEST_EQ(r, "\"foo\\\\bar, \\\" *\"");
+
+  ss << quoted(s1);
+  ss >> quoted(r);
+  BOOST_TEST_EQ(r, s1);
+
+  ss << quoted(s1.c_str());
+  ss >> quoted(r);
+  BOOST_TEST_EQ(r, s1);
+
+  string s2("'Jack & Jill'");                                 
+
+  ss << quoted(s2, '&', '\'');
+  ss >> r;
+  BOOST_TEST_EQ(r, "'&'Jack && Jill&''");
+
+  ss << quoted(s2, '&', '\'');
+  ss >> quoted(r, '&', '\'');
+  BOOST_TEST_EQ(r, s2);
+
+  wstring ws1(L"foo$bar, \" *");
+  wstring wr; // test results
+
+  wss << quoted(ws1, L'$');
+  wss >> wr;
+  BOOST_TEST(wr == wstring(L"\"foo$$bar, $\" *\""));
+
+  wss << quoted(ws1, L'$');
+  wss >> quoted(wr,  L'$');
+  BOOST_TEST(wr == ws1);
+
+  const string s3("const string");
+  ss << quoted(s3);
+  ss >> quoted(r);
+  BOOST_TEST_EQ(r, s3);
+
+  //  missing end delimiter test
+  ss << "\"abc";      // load ss with faulty quoting
+  ss >> quoted(r);    // this loops if istream error/eof not detected
+  BOOST_TEST_EQ(r, "abc");
+
+  //  no initial delmiter test
+  ss << "abc";
+  ss >> quoted(r);
+  BOOST_TEST_EQ(r, "abc");
+
+  //  no initial delmiter, space in ss
+  ss << "abc def";
+  ss >> quoted(r);
+  BOOST_TEST_EQ(r, "abc");
+
+  // these should fail to compile because the arguments are const:
+  //   ss >> quoted(s1);
+  //   ss >> quoted("foo");
+
+  return 0;
+}