Boost logo

Boost-Commit :

From: technews_at_[hidden]
Date: 2008-02-23 01:07:59


Author: turkanis
Date: 2008-02-23 01:07:59 EST (Sat, 23 Feb 2008)
New Revision: 43395
URL: http://svn.boost.org/trac/boost/changeset/43395

Log:
updated to test close() on filtering streambufs
Text files modified:
   trunk/libs/iostreams/test/close_test.cpp | 222 ++++++++++++++++++++++++++++++++-------
   1 files changed, 179 insertions(+), 43 deletions(-)

Modified: trunk/libs/iostreams/test/close_test.cpp
==============================================================================
--- trunk/libs/iostreams/test/close_test.cpp (original)
+++ trunk/libs/iostreams/test/close_test.cpp 2008-02-23 01:07:59 EST (Sat, 23 Feb 2008)
@@ -10,12 +10,12 @@
  *
  * File: libs/iostreams/test/close_test.cpp
  * Date: Sun Dec 09 16:12:23 MST 2007
- * Copyright: 2007-2008 CodeRage, LLC
+ * Copyright: 2007 CodeRage
  * Author: Jonathan Turkanis
- * Contact: turkanis at coderage dot com
  */
 
 #include <boost/iostreams/chain.hpp>
+#include <boost/iostreams/filtering_streambuf.hpp>
 #include <boost/iostreams/stream.hpp>
 #include <boost/test/test_tools.hpp>
 #include <boost/test/unit_test.hpp>
@@ -33,8 +33,8 @@
 {
     // Test input filter and device
     {
- operation_sequence seq;
- chain<input> ch;
+ operation_sequence seq;
+ filtering_streambuf<input> ch;
 
         // Test chain::pop()
         ch.push(closable_filter<input>(seq.new_operation(2)));
@@ -42,6 +42,12 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(closable_device<input>(seq.new_operation(1)));
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(closable_device<input>(seq.new_operation(1)));
@@ -51,10 +57,9 @@
 
     // Test bidirectional filter and device
     {
- operation_sequence seq;
- chain<input> ch;
+ operation_sequence seq;
+ filtering_streambuf<input> ch;
 
-
         // Test chain::pop()
         ch.push(
             closable_filter<bidirectional>(
@@ -71,6 +76,17 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(
+ closable_device<bidirectional>(
+ seq.new_operation(1),
+ seq.new_operation(4)
+ )
+ );
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(
@@ -85,8 +101,8 @@
 
     // Test seekable filter and device
     {
- operation_sequence seq;
- chain<input> ch;
+ operation_sequence seq;
+ filtering_streambuf<input> ch;
 
         // Test chain::pop()
         ch.push(closable_filter<seekable>(seq.new_operation(1)));
@@ -94,6 +110,12 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(closable_device<seekable>(seq.new_operation(2)));
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(closable_device<seekable>(seq.new_operation(2)));
@@ -103,9 +125,9 @@
 
     // Test dual-user filter
     {
- operation_sequence seq;
- chain<input> ch;
- operation dummy;
+ operation_sequence seq;
+ filtering_streambuf<input> ch;
+ operation dummy;
 
         // Test chain::pop()
         ch.push(
@@ -117,6 +139,12 @@
         ch.push(closable_device<input>(seq.new_operation(1)));
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(closable_device<input>(seq.new_operation(1)));
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
         // Test filter reuse and chain::reset()
         seq.reset();
@@ -127,14 +155,20 @@
 
     // Test direct source
     {
- operation_sequence seq;
- chain<input> ch;
+ operation_sequence seq;
+ filtering_streambuf<input> ch;
 
         // Test chain::pop()
         ch.push(closable_filter<input>(seq.new_operation(2)));
         ch.push(closable_device<direct_input>(seq.new_operation(1)));
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(closable_device<direct_input>(seq.new_operation(1)));
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
         // Test filter reuse and chain::reset()
         seq.reset();
@@ -145,8 +179,8 @@
 
     // Test direct bidirectional device
     {
- operation_sequence seq;
- chain<input> ch;
+ operation_sequence seq;
+ filtering_streambuf<input> ch;
 
         // Test chain::pop()
         ch.push(closable_filter<input>(seq.new_operation(2)));
@@ -159,6 +193,17 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(
+ closable_device<direct_bidirectional>(
+ seq.new_operation(1),
+ seq.new_operation(3)
+ )
+ );
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(
@@ -173,8 +218,8 @@
 
     // Test direct seekable device
     {
- operation_sequence seq;
- chain<input> ch;
+ operation_sequence seq;
+ filtering_streambuf<input> ch;
 
         // Test chain::pop()
         ch.push(closable_filter<input>(seq.new_operation(1)));
@@ -182,6 +227,12 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(closable_device<direct_seekable>(seq.new_operation(2)));
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(closable_device<direct_seekable>(seq.new_operation(2)));
@@ -194,8 +245,8 @@
 {
     // Test output filter and device
     {
- operation_sequence seq;
- chain<output> ch;
+ operation_sequence seq;
+ filtering_streambuf<output> ch;
 
         // Test chain::pop()
         ch.push(closable_filter<output>(seq.new_operation(1)));
@@ -203,6 +254,12 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(closable_device<output>(seq.new_operation(2)));
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(closable_device<output>(seq.new_operation(2)));
@@ -212,9 +269,8 @@
 
     // Test bidirectional filter and device
     {
- operation_sequence seq;
- chain<output> ch;
-
+ operation_sequence seq;
+ filtering_streambuf<output> ch;
         
         // Test chain::pop()
         ch.push(
@@ -232,6 +288,17 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(
+ closable_device<bidirectional>(
+ seq.new_operation(1),
+ seq.new_operation(4)
+ )
+ );
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(
@@ -246,8 +313,8 @@
 
     // Test seekable filter and device
     {
- operation_sequence seq;
- chain<output> ch;
+ operation_sequence seq;
+ filtering_streambuf<output> ch;
 
         // Test chain::pop()
         ch.push(closable_filter<seekable>(seq.new_operation(1)));
@@ -255,6 +322,12 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(closable_device<seekable>(seq.new_operation(2)));
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(closable_device<seekable>(seq.new_operation(2)));
@@ -264,9 +337,9 @@
 
     // Test dual-user filter
     {
- operation_sequence seq;
- chain<output> ch;
- operation dummy;
+ operation_sequence seq;
+ filtering_streambuf<output> ch;
+ operation dummy;
 
         // Test chain::pop()
         ch.push(
@@ -279,6 +352,12 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(closable_device<output>(seq.new_operation(3)));
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(closable_device<output>(seq.new_operation(3)));
@@ -288,8 +367,8 @@
 
     // Test direct sink
     {
- operation_sequence seq;
- chain<output> ch;
+ operation_sequence seq;
+ filtering_streambuf<output> ch;
 
         // Test chain::pop()
         ch.push(closable_filter<output>(seq.new_operation(1)));
@@ -297,6 +376,12 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(closable_device<direct_output>(seq.new_operation(2)));
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(closable_device<direct_output>(seq.new_operation(2)));
@@ -306,8 +391,8 @@
 
     // Test direct bidirectional device
     {
- operation_sequence seq;
- chain<output> ch;
+ operation_sequence seq;
+ filtering_streambuf<output> ch;
 
         // Test chain::pop()
         ch.push(closable_filter<output>(seq.new_operation(2)));
@@ -320,6 +405,17 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(
+ closable_device<direct_bidirectional>(
+ seq.new_operation(1),
+ seq.new_operation(3)
+ )
+ );
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(
@@ -334,8 +430,8 @@
 
     // Test direct seekable device
     {
- operation_sequence seq;
- chain<output> ch;
+ operation_sequence seq;
+ filtering_streambuf<output> ch;
 
         // Test chain::pop()
         ch.push(closable_filter<output>(seq.new_operation(1)));
@@ -343,6 +439,12 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(closable_device<direct_seekable>(seq.new_operation(2)));
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(closable_device<direct_seekable>(seq.new_operation(2)));
@@ -355,8 +457,8 @@
 {
     // Test bidirectional filter and device
     {
- operation_sequence seq;
- chain<bidirectional> ch;
+ operation_sequence seq;
+ filtering_streambuf<bidirectional> ch;
         
         // Test chain::pop()
         ch.push(
@@ -374,6 +476,17 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(
+ closable_device<bidirectional>(
+ seq.new_operation(1),
+ seq.new_operation(4)
+ )
+ );
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(
@@ -388,8 +501,8 @@
 
     // Test direct bidirectional device
     {
- operation_sequence seq;
- chain<bidirectional> ch;
+ operation_sequence seq;
+ filtering_streambuf<bidirectional> ch;
 
         // Test chain::pop()
         ch.push(
@@ -407,6 +520,17 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(
+ closable_device<direct_bidirectional>(
+ seq.new_operation(1),
+ seq.new_operation(4)
+ )
+ );
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(
@@ -424,8 +548,8 @@
 {
     // Test seekable filter and device
     {
- operation_sequence seq;
- chain<seekable> ch;
+ operation_sequence seq;
+ filtering_streambuf<seekable> ch;
 
         // Test chain::pop()
         ch.push(closable_filter<seekable>(seq.new_operation(1)));
@@ -433,6 +557,12 @@
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(closable_device<seekable>(seq.new_operation(2)));
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(closable_device<seekable>(seq.new_operation(2)));
@@ -442,15 +572,21 @@
 
     // Test direct seekable device
     {
- operation_sequence seq;
- chain<output> ch;
+ operation_sequence seq;
+ filtering_streambuf<seekable> ch;
 
         // Test chain::pop()
- ch.push(closable_filter<output>(seq.new_operation(1)));
+ ch.push(closable_filter<seekable>(seq.new_operation(1)));
         ch.push(closable_device<direct_seekable>(seq.new_operation(2)));
         BOOST_CHECK_NO_THROW(ch.pop());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
 
+ // Test filter reuse and io::close()
+ seq.reset();
+ ch.push(closable_device<direct_seekable>(seq.new_operation(2)));
+ BOOST_CHECK_NO_THROW(io::close(ch));
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+
         // Test filter reuse and chain::reset()
         seq.reset();
         ch.push(closable_device<direct_seekable>(seq.new_operation(2)));


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