|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60228 - in trunk: boost/iostreams libs/iostreams/test
From: daniel_james_at_[hidden]
Date: 2010-03-06 10:17:38
Author: danieljames
Date: 2010-03-06 10:17:38 EST (Sat, 06 Mar 2010)
New Revision: 60228
URL: http://svn.boost.org/trac/boost/changeset/60228
Log:
Fix write_device_impl<ostream_tag>
And enchance the newline tests so that they test it.
Refs #3839
Text files modified:
trunk/boost/iostreams/write.hpp | 2
trunk/libs/iostreams/test/newline_test.cpp | 52 ++++++++++++++++++++++++++++++---------
2 files changed, 41 insertions(+), 13 deletions(-)
Modified: trunk/boost/iostreams/write.hpp
==============================================================================
--- trunk/boost/iostreams/write.hpp (original)
+++ trunk/boost/iostreams/write.hpp 2010-03-06 10:17:38 EST (Sat, 06 Mar 2010)
@@ -83,7 +83,7 @@
{
typedef typename char_type_of<T>::type char_type;
typedef BOOST_IOSTREAMS_CHAR_TRAITS(char_type) traits_type;
- return !traits_type::eq_int_type( t.rdbuf()->s.sputc(),
+ return !traits_type::eq_int_type( t.rdbuf()->sputc(c),
traits_type::eof() );
}
Modified: trunk/libs/iostreams/test/newline_test.cpp
==============================================================================
--- trunk/libs/iostreams/test/newline_test.cpp (original)
+++ trunk/libs/iostreams/test/newline_test.cpp 2010-03-06 10:17:38 EST (Sat, 06 Mar 2010)
@@ -163,30 +163,58 @@
BOOST_CHECK(test_input_filter(newline_filter(newline::mac), mixed, mac));
}
+// Verify that a filter works as expected with both a non-blocking sink
+// and a normal output stream.
+//
+// test_output_filter only tests for a non-blocking sink.
+// TODO: Other tests should probably test with an output stream.
+
+template<typename Filter>
+bool my_test_output_filter(Filter filter,
+ const std::string& input,
+ const std::string& output)
+{
+ const std::streamsize default_increment = 5;
+
+ for ( int inc = default_increment;
+ inc < default_increment * 40;
+ inc += default_increment )
+ {
+ io::array_source src(input.data(), input.data() + input.size());
+
+ std::ostringstream stream;
+ io::copy(src, compose(filter, stream));
+ if (stream.str() != output )
+ return false;
+
+ }
+ return test_output_filter(filter, input, output);
+}
+
void write_newline_filter()
{
using namespace io;
// Test converting to posix format.
- BOOST_CHECK(test_output_filter(newline_filter(newline::posix), posix, posix));
- BOOST_CHECK(test_output_filter(newline_filter(newline::posix), dos, posix));
- BOOST_CHECK(test_output_filter(newline_filter(newline::posix), mac, posix));
- BOOST_CHECK(test_output_filter(newline_filter(newline::posix), mixed, posix));
+ BOOST_CHECK(my_test_output_filter(newline_filter(newline::posix), posix, posix));
+ BOOST_CHECK(my_test_output_filter(newline_filter(newline::posix), dos, posix));
+ BOOST_CHECK(my_test_output_filter(newline_filter(newline::posix), mac, posix));
+ BOOST_CHECK(my_test_output_filter(newline_filter(newline::posix), mixed, posix));
// Test converting to dos format.
- BOOST_CHECK(test_output_filter(newline_filter(newline::dos), posix, dos));
- BOOST_CHECK(test_output_filter(newline_filter(newline::dos), dos, dos));
- BOOST_CHECK(test_output_filter(newline_filter(newline::dos), mac, dos));
- BOOST_CHECK(test_output_filter(newline_filter(newline::dos), mixed, dos));
+ BOOST_CHECK(my_test_output_filter(newline_filter(newline::dos), posix, dos));
+ BOOST_CHECK(my_test_output_filter(newline_filter(newline::dos), dos, dos));
+ BOOST_CHECK(my_test_output_filter(newline_filter(newline::dos), mac, dos));
+ BOOST_CHECK(my_test_output_filter(newline_filter(newline::dos), mixed, dos));
// Test converting to mac format.
- BOOST_CHECK(test_output_filter(newline_filter(newline::mac), posix, mac));
- BOOST_CHECK(test_output_filter(newline_filter(newline::mac), dos, mac));
- BOOST_CHECK(test_output_filter(newline_filter(newline::mac), mac, mac));
- BOOST_CHECK(test_output_filter(newline_filter(newline::mac), mixed, mac));
+ BOOST_CHECK(my_test_output_filter(newline_filter(newline::mac), posix, mac));
+ BOOST_CHECK(my_test_output_filter(newline_filter(newline::mac), dos, mac));
+ BOOST_CHECK(my_test_output_filter(newline_filter(newline::mac), mac, mac));
+ BOOST_CHECK(my_test_output_filter(newline_filter(newline::mac), mixed, mac));
}
void test_input_against_flags(int flags, const std::string& input, bool read)
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