]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/iostreams/test/write_bidir_filter_test.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / iostreams / test / write_bidir_filter_test.hpp
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.)
5
6 // See http://www.boost.org/libs/iostreams for documentation.
7
8 #ifndef BOOST_IOSTREAMS_TEST_WRITE_INOUT_FILTER_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_TEST_WRITE_INOUT_FILTER_HPP_INCLUDED
10
11 #include <fstream>
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"
19
20 void write_bidirectional_filter_test()
21 {
22 using namespace std;
23 using namespace boost;
24 using namespace boost::iostreams;
25 using namespace boost::iostreams::test;
26
27 lowercase_file lower;
28 BOOST_IOS::openmode mode = out_mode | BOOST_IOS::trunc;
29
30 {
31 temp_file lower2;
32 filebuf dest;
33 filtering_stream<bidirectional> out;
34 dest.open(lower2.name().c_str(), mode);
35 out.push(combine(toupper_filter(), tolower_filter()));
36 out.push(dest);
37 write_data_in_chars(out);
38 out.reset();
39 dest.close();
40 BOOST_CHECK_MESSAGE(
41 compare_files(lower2.name(), lower.name()),
42 "failed writing to a filtering_stream<bidirectional> in chars with an "
43 "output filter"
44 );
45 }
46
47 {
48 // OutputFilter.
49 temp_file lower2;
50 filebuf dest;
51 filtering_stream<bidirectional> out;
52 out.push(combine(toupper_filter(), tolower_filter()));
53 dest.open(lower2.name().c_str(), mode);
54 out.push(dest);
55 write_data_in_chunks(out);
56 out.reset();
57 dest.close();
58 BOOST_CHECK_MESSAGE(
59 compare_files(lower2.name(), lower.name()),
60 "failed writing to a filtering_stream<bidirectional> in chunks with an "
61 "output filter"
62 );
63 }
64
65 {
66 temp_file lower2;
67 filebuf dest;
68 filtering_stream<bidirectional> out;
69 out.push(combine(toupper_filter(), tolower_multichar_filter()), 0);
70 dest.open(lower2.name().c_str(), mode);
71 out.push(dest);
72 write_data_in_chars(out);
73 out.reset();
74 dest.close();
75 BOOST_CHECK_MESSAGE(
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"
79 );
80 }
81
82 {
83 temp_file lower2;
84 filebuf dest;
85 filtering_stream<bidirectional> out;
86 out.push(combine(toupper_filter(), tolower_multichar_filter()), 0);
87 dest.open(lower2.name().c_str(), mode);
88 out.push(dest);
89 write_data_in_chunks(out);
90 out.reset();
91 dest.close();
92 BOOST_CHECK_MESSAGE(
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"
96 );
97 }
98
99 {
100 temp_file lower2;
101 filebuf dest;
102 filtering_stream<bidirectional> out;
103 out.push(combine(toupper_filter(), tolower_multichar_filter()));
104 dest.open(lower2.name().c_str(), mode);
105 out.push(dest);
106 write_data_in_chars(out);
107 out.reset();
108 dest.close();
109 BOOST_CHECK_MESSAGE(
110 compare_files(lower2.name(), lower.name()),
111 "failed writing to a filtering_stream<bidirectional> in chars "
112 "with a multichar output filter"
113 );
114 }
115
116 {
117 temp_file lower2;
118 filebuf dest;
119 filtering_stream<bidirectional> out;
120 out.push(combine(toupper_filter(), tolower_multichar_filter()));
121 dest.open(lower2.name().c_str(), mode);
122 out.push(dest);
123 write_data_in_chunks(out);
124 out.reset();
125 dest.close();
126 BOOST_CHECK_MESSAGE(
127 compare_files(lower2.name(), lower.name()),
128 "failed writing to a filtering_stream<bidirectional> in chunks "
129 "with a buffered output filter"
130 );
131 }
132 }
133
134 #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_BIDIRECTIONAL_FILTER_HPP_INCLUDED