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_WRITE_OUTPUT_OSTREAM_HPP_INCLUDED |
---|
8 | #define BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_OSTREAM_HPP_INCLUDED |
---|
9 | |
---|
10 | #include <fstream> |
---|
11 | #include <boost/iostreams/filtering_stream.hpp> |
---|
12 | #include <boost/test/test_tools.hpp> |
---|
13 | #include "detail/sequence.hpp" |
---|
14 | #include "detail/temp_file.hpp" |
---|
15 | #include "detail/verification.hpp" |
---|
16 | |
---|
17 | void write_output_ostream_test() |
---|
18 | { |
---|
19 | using namespace std; |
---|
20 | using namespace boost; |
---|
21 | using namespace boost::iostreams; |
---|
22 | using namespace boost::iostreams::test; |
---|
23 | |
---|
24 | test_file test; |
---|
25 | |
---|
26 | { |
---|
27 | temp_file test2; |
---|
28 | { |
---|
29 | ofstream dest(test2.name().c_str(), out_mode); |
---|
30 | filtering_ostream out(dest, 0); |
---|
31 | write_data_in_chars(out); |
---|
32 | } |
---|
33 | BOOST_CHECK_MESSAGE( |
---|
34 | compare_files(test2.name(), test.name()), |
---|
35 | "failed writing to filtering_ostream based on an ostream " |
---|
36 | "in chars with no buffer" |
---|
37 | ); |
---|
38 | } |
---|
39 | |
---|
40 | { |
---|
41 | temp_file test2; |
---|
42 | { |
---|
43 | ofstream dest(test2.name().c_str(), out_mode); |
---|
44 | filtering_ostream out(dest, 0); |
---|
45 | write_data_in_chunks(out); |
---|
46 | } |
---|
47 | BOOST_CHECK_MESSAGE( |
---|
48 | compare_files(test2.name(), test.name()), |
---|
49 | "failed writing to filtering_ostream based on an ostream " |
---|
50 | "in chunks with no buffer" |
---|
51 | ); |
---|
52 | } |
---|
53 | |
---|
54 | { |
---|
55 | test_file test2; |
---|
56 | { |
---|
57 | ofstream dest(test2.name().c_str(), out_mode); |
---|
58 | filtering_ostream out(dest); |
---|
59 | write_data_in_chars(out); |
---|
60 | } |
---|
61 | BOOST_CHECK_MESSAGE( |
---|
62 | compare_files(test2.name(), test.name()), |
---|
63 | "failed writing to filtering_ostream based on an ostream " |
---|
64 | "in chars with large buffer" |
---|
65 | ); |
---|
66 | } |
---|
67 | |
---|
68 | { |
---|
69 | temp_file test2; |
---|
70 | { |
---|
71 | ofstream dest(test2.name().c_str(), out_mode); |
---|
72 | filtering_ostream out(dest); |
---|
73 | write_data_in_chunks(out); |
---|
74 | } |
---|
75 | BOOST_CHECK_MESSAGE( |
---|
76 | compare_files(test2.name(), test.name()), |
---|
77 | "failed writing to filtering_ostream based on an ostream " |
---|
78 | "in chunks with large buffer" |
---|
79 | ); |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_OSTREAM_HPP_INCLUDED |
---|