]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_READ_INPUT_FILTER_HPP_INCLUDED | |
9 | #define BOOST_IOSTREAMS_TEST_READ_INPUT_FILTER_HPP_INCLUDED | |
10 | ||
11 | #include <fstream> | |
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_input_filter_test() | |
21 | { | |
22 | using namespace std; | |
23 | using namespace boost; | |
24 | using namespace boost::iostreams; | |
25 | using namespace boost::iostreams::test; | |
26 | ||
27 | test_file test; | |
28 | uppercase_file upper; | |
29 | ||
30 | { | |
31 | filtering_istream first; | |
32 | first.push(toupper_filter()); | |
33 | first.push(file_source(test.name())); | |
34 | ifstream second(upper.name().c_str()); | |
35 | BOOST_CHECK_MESSAGE( | |
36 | compare_streams_in_chars(first, second), | |
37 | "failed reading from a filtering_istream in chars with an " | |
38 | "input filter" | |
39 | ); | |
40 | } | |
41 | ||
42 | { | |
43 | filtering_istream first; | |
44 | first.push(toupper_filter()); | |
45 | first.push(file_source(test.name())); | |
46 | ifstream second(upper.name().c_str()); | |
47 | BOOST_CHECK_MESSAGE( | |
48 | compare_streams_in_chunks(first, second), | |
49 | "failed reading from a filtering_istream in chunks with an " | |
50 | "input filter" | |
51 | ); | |
52 | } | |
53 | ||
54 | { | |
55 | filtering_istream first; | |
56 | first.push(toupper_multichar_filter(), 0); | |
57 | first.push(file_source(test.name())); | |
58 | ifstream second(upper.name().c_str()); | |
59 | BOOST_CHECK_MESSAGE( | |
60 | compare_streams_in_chars(first, second), | |
61 | "failed reading from a filtering_istream in chars with a " | |
62 | "multichar input filter with no buffer" | |
63 | ); | |
64 | } | |
65 | ||
66 | { | |
67 | filtering_istream first; | |
68 | first.push(toupper_multichar_filter(), 0); | |
69 | first.push(file_source(test.name())); | |
70 | ifstream second(upper.name().c_str()); | |
71 | BOOST_CHECK_MESSAGE( | |
72 | compare_streams_in_chunks(first, second), | |
73 | "failed reading from a filtering_istream in chunks with a " | |
74 | "multichar input filter with no buffer" | |
75 | ); | |
76 | } | |
77 | ||
78 | { | |
79 | test_file src; | |
80 | filtering_istream first; | |
81 | first.push(toupper_multichar_filter()); | |
82 | first.push(file_source(src.name())); | |
83 | ifstream second(upper.name().c_str()); | |
84 | BOOST_CHECK_MESSAGE( | |
85 | compare_streams_in_chars(first, second), | |
86 | "failed reading from a filtering_istream in chars with a " | |
87 | "multichar input filter" | |
88 | ); | |
89 | } | |
90 | ||
91 | { | |
92 | test_file src; | |
93 | filtering_istream first; | |
94 | first.push(toupper_multichar_filter()); | |
95 | first.push(file_source(src.name())); | |
96 | ifstream second(upper.name().c_str()); | |
97 | BOOST_CHECK_MESSAGE( | |
98 | compare_streams_in_chunks(first, second), | |
99 | "failed reading from a filtering_istream in chunks with a " | |
100 | "multichar input filter" | |
101 | ); | |
102 | } | |
103 | } | |
104 | ||
105 | #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_FILTER_HPP_INCLUDED |