1 | // (C) Copyright Jonathan Turkanis 2004 |
---|
2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
---|
3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) |
---|
4 | |
---|
5 | // See http://www.boost.org/libs/iostreams for documentation. |
---|
6 | |
---|
7 | #ifndef BOOST_IOSTREAMS_TEST_READ_BIDIRECTIONAL_FILTER_HPP_INCLUDED |
---|
8 | #define BOOST_IOSTREAMS_TEST_READ_BIDIRECTIONAL_FILTER_HPP_INCLUDED |
---|
9 | |
---|
10 | #include <fstream> |
---|
11 | #include <boost/iostreams/combine.hpp> |
---|
12 | #include <boost/iostreams/device/file.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 read_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 | uppercase_file upper; |
---|
28 | |
---|
29 | //{ |
---|
30 | // test_file src; |
---|
31 | // temp_file dest; // Dummy. |
---|
32 | // filtering_stream<bidirectional> first; |
---|
33 | // first.push(combine(toupper_filter(), tolower_filter())); |
---|
34 | // first.push( |
---|
35 | // combine(file_source(src.name()), file_sink(dest.name())) |
---|
36 | // ); |
---|
37 | // ifstream second(upper.name().c_str()); |
---|
38 | // BOOST_CHECK_MESSAGE( |
---|
39 | // compare_streams_in_chars(first, second), |
---|
40 | // "failed reading from filtering_stream<bidirectional> in chars with an " |
---|
41 | // "input filter" |
---|
42 | // ); |
---|
43 | //} |
---|
44 | |
---|
45 | { |
---|
46 | test_file src; |
---|
47 | temp_file dest; // Dummy. |
---|
48 | filtering_stream<bidirectional> first; |
---|
49 | first.push(combine(toupper_filter(), tolower_filter())); |
---|
50 | first.push( |
---|
51 | combine(file_source(src.name()), file_sink(dest.name())) |
---|
52 | ); |
---|
53 | ifstream second(upper.name().c_str()); |
---|
54 | BOOST_CHECK_MESSAGE( |
---|
55 | compare_streams_in_chunks(first, second), |
---|
56 | "failed reading from filtering_stream<bidirectional> in chunks with an " |
---|
57 | "input filter" |
---|
58 | ); |
---|
59 | } |
---|
60 | |
---|
61 | //{ |
---|
62 | // test_file src; |
---|
63 | // temp_file dest; // Dummy. |
---|
64 | // filtering_stream<bidirectional> first( |
---|
65 | // combine(toupper_multichar_filter(), tolower_filter()), 0 |
---|
66 | // ); |
---|
67 | // first.push( |
---|
68 | // combine(file_source(src.name()), file_sink(dest.name())) |
---|
69 | // ); |
---|
70 | // ifstream second(upper.name().c_str()); |
---|
71 | // BOOST_CHECK_MESSAGE( |
---|
72 | // compare_streams_in_chars(first, second), |
---|
73 | // "failed reading from filtering_stream<bidirectional> in chars with " |
---|
74 | // "a multichar input filter with no buffer" |
---|
75 | // ); |
---|
76 | //} |
---|
77 | |
---|
78 | //{ |
---|
79 | // test_file src; |
---|
80 | // temp_file dest; // Dummy. |
---|
81 | // filtering_stream<bidirectional> first( |
---|
82 | // combine(toupper_multichar_filter(), tolower_filter()), 0 |
---|
83 | // ); |
---|
84 | // first.push( |
---|
85 | // combine(file_source(src.name()), file_sink(dest.name())) |
---|
86 | // ); |
---|
87 | // ifstream second(upper.name().c_str()); |
---|
88 | // BOOST_CHECK_MESSAGE( |
---|
89 | // compare_streams_in_chunks(first, second), |
---|
90 | // "failed reading from filtering_stream<bidirectional> in chunks " |
---|
91 | // "with a multichar input filter with no buffer" |
---|
92 | // ); |
---|
93 | //} |
---|
94 | |
---|
95 | //{ |
---|
96 | // test_file src; |
---|
97 | // temp_file dest; // Dummy. |
---|
98 | // filtering_stream<bidirectional> first( |
---|
99 | // combine(toupper_multichar_filter(), tolower_filter()) |
---|
100 | // ); |
---|
101 | // first.push( |
---|
102 | // combine(file_source(src.name()), file_sink(dest.name())) |
---|
103 | // ); |
---|
104 | // ifstream second(upper.name().c_str()); |
---|
105 | // BOOST_CHECK_MESSAGE( |
---|
106 | // compare_streams_in_chars(first, second), |
---|
107 | // "failed reading from filtering_stream<bidirectional> in chars with a " |
---|
108 | // "multichar input filter" |
---|
109 | // ); |
---|
110 | //} |
---|
111 | |
---|
112 | //{ |
---|
113 | // test_file src; |
---|
114 | // temp_file dest; // Dummy. |
---|
115 | // filtering_stream<bidirectional> first( |
---|
116 | // combine(toupper_multichar_filter(), tolower_filter()) |
---|
117 | // ); |
---|
118 | // first.push( |
---|
119 | // combine(file_source(src.name()), file_sink(dest.name())) |
---|
120 | // ); |
---|
121 | // ifstream second(upper.name().c_str()); |
---|
122 | // BOOST_CHECK_MESSAGE( |
---|
123 | // compare_streams_in_chunks(first, second), |
---|
124 | // "failed reading from filtering_stream<bidirectional> in chunks " |
---|
125 | // "with a multichar input filter" |
---|
126 | // ); |
---|
127 | //} |
---|
128 | } |
---|
129 | |
---|
130 | #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_BIDIRECTIONAL_FILTER_HPP_INCLUDED |
---|