1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
2 // (C) Copyright 2004-2007 Jonathan Turkanis
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
6 // See http://www.boost.org/libs/iostreams for documentation.
8 #ifndef BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_ITERATOR_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_ITERATOR_HPP_INCLUDED
12 #include <iterator> // Back inserter.
14 #include <boost/iostreams/filtering_stream.hpp>
15 #include <boost/test/test_tools.hpp>
16 #include "detail/sequence.hpp"
17 #include "detail/temp_file.hpp"
18 #include "detail/verification.hpp"
20 // Note: adding raw inserter iterators to chains is not supported
23 void write_output_iterator_test()
26 using namespace boost;
27 using namespace boost::iostreams;
28 using namespace boost::iostreams::test;
34 filtering_ostream out;
35 out.push(std::back_inserter(first), 0);
36 write_data_in_chars(out);
37 ifstream second(test.name().c_str());
39 compare_container_and_stream(first, second),
40 "failed writing to filtering_ostream based on an "
41 "output iterator in chars with no buffer"
47 filtering_ostream out;
48 out.push(std::back_inserter(first), 0);
49 write_data_in_chunks(out);
50 ifstream second(test.name().c_str());
52 compare_container_and_stream(first, second),
53 "failed writing to filtering_ostream based on an "
54 "output iterator in chunks with no buffer"
60 filtering_ostream out;
61 out.push(std::back_inserter(first));
62 write_data_in_chars(out);
63 ifstream second(test.name().c_str());
65 compare_container_and_stream(first, second),
66 "failed writing to filtering_ostream based on an "
67 "output iterator in chars with large buffer"
73 filtering_ostream out;
74 out.push(std::back_inserter(first));
75 write_data_in_chunks(out);
76 ifstream second(test.name().c_str());
78 compare_container_and_stream(first, second),
79 "failed writing to filtering_ostream based on an "
80 "output iterator in chunks with large buffer"
85 #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_ITERATOR_HPP_INCLUDED