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_INOUT_FILTER_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_TEST_WRITE_INOUT_FILTER_HPP_INCLUDED
12 #include <boost/iostreams/combine.hpp>
13 #include <boost/iostreams/filtering_stream.hpp>
14 #include <boost/test/test_tools.hpp>
15 #include "detail/filters.hpp"
16 #include "detail/sequence.hpp"
17 #include "detail/temp_file.hpp"
18 #include "detail/verification.hpp"
20 void write_bidirectional_filter_test()
23 using namespace boost;
24 using namespace boost::iostreams;
25 using namespace boost::iostreams::test;
28 BOOST_IOS::openmode mode = out_mode | BOOST_IOS::trunc;
33 filtering_stream<bidirectional> out;
34 dest.open(lower2.name().c_str(), mode);
35 out.push(combine(toupper_filter(), tolower_filter()));
37 write_data_in_chars(out);
41 compare_files(lower2.name(), lower.name()),
42 "failed writing to a filtering_stream<bidirectional> in chars with an "
51 filtering_stream<bidirectional> out;
52 out.push(combine(toupper_filter(), tolower_filter()));
53 dest.open(lower2.name().c_str(), mode);
55 write_data_in_chunks(out);
59 compare_files(lower2.name(), lower.name()),
60 "failed writing to a filtering_stream<bidirectional> in chunks with an "
68 filtering_stream<bidirectional> out;
69 out.push(combine(toupper_filter(), tolower_multichar_filter()), 0);
70 dest.open(lower2.name().c_str(), mode);
72 write_data_in_chars(out);
76 compare_files(lower2.name(), lower.name()),
77 "failed writing to a filtering_stream<bidirectional> in chars "
78 "with a multichar output filter with no buffer"
85 filtering_stream<bidirectional> out;
86 out.push(combine(toupper_filter(), tolower_multichar_filter()), 0);
87 dest.open(lower2.name().c_str(), mode);
89 write_data_in_chunks(out);
93 compare_files(lower2.name(), lower.name()),
94 "failed writing to a filtering_stream<bidirectional> in chunks "
95 "with a multichar output filter with no buffer"
102 filtering_stream<bidirectional> out;
103 out.push(combine(toupper_filter(), tolower_multichar_filter()));
104 dest.open(lower2.name().c_str(), mode);
106 write_data_in_chars(out);
110 compare_files(lower2.name(), lower.name()),
111 "failed writing to a filtering_stream<bidirectional> in chars "
112 "with a multichar output filter"
119 filtering_stream<bidirectional> out;
120 out.push(combine(toupper_filter(), tolower_multichar_filter()));
121 dest.open(lower2.name().c_str(), mode);
123 write_data_in_chunks(out);
127 compare_files(lower2.name(), lower.name()),
128 "failed writing to a filtering_stream<bidirectional> in chunks "
129 "with a buffered output filter"
134 #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_BIDIRECTIONAL_FILTER_HPP_INCLUDED