| 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_BIDIRECTIONAL_HPP_INCLUDED |
|---|
| 8 | #define BOOST_IOSTREAMS_TEST_WRITE_BIDIRECTIONAL_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/temp_file.hpp" |
|---|
| 16 | #include "detail/verification.hpp" |
|---|
| 17 | |
|---|
| 18 | void write_bidirectional_test() |
|---|
| 19 | { |
|---|
| 20 | using namespace std; |
|---|
| 21 | using namespace boost; |
|---|
| 22 | using namespace boost::iostreams; |
|---|
| 23 | using namespace boost::iostreams::test; |
|---|
| 24 | |
|---|
| 25 | test_file test; |
|---|
| 26 | |
|---|
| 27 | { |
|---|
| 28 | temp_file dest; |
|---|
| 29 | temp_file src; // Dummy; |
|---|
| 30 | filtering_stream<bidirectional> out( |
|---|
| 31 | combine(file_source(src.name()), file_sink(dest.name(), out_mode)), 0 |
|---|
| 32 | ); |
|---|
| 33 | write_data_in_chars(out); |
|---|
| 34 | out.reset(); |
|---|
| 35 | BOOST_CHECK_MESSAGE( |
|---|
| 36 | compare_files(dest.name(), test.name()), |
|---|
| 37 | "failed writing to filtering_stream<bidirectional> in chars " |
|---|
| 38 | "with no buffer" |
|---|
| 39 | ); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | { |
|---|
| 43 | temp_file dest; |
|---|
| 44 | temp_file src; // Dummy; |
|---|
| 45 | filtering_stream<bidirectional> out( |
|---|
| 46 | combine(file_source(src.name()), file_sink(dest.name(), out_mode)), 0 |
|---|
| 47 | ); |
|---|
| 48 | write_data_in_chunks(out); |
|---|
| 49 | out.reset(); |
|---|
| 50 | BOOST_CHECK_MESSAGE( |
|---|
| 51 | compare_files(dest.name(), test.name()), |
|---|
| 52 | "failed writing to filtering_stream<bidirectional> in chunks " |
|---|
| 53 | "with no buffer" |
|---|
| 54 | ); |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | { |
|---|
| 58 | temp_file dest; |
|---|
| 59 | temp_file src; // Dummy; |
|---|
| 60 | filtering_stream<bidirectional> out( |
|---|
| 61 | combine(file_source(src.name()), file_sink(dest.name(), out_mode)) |
|---|
| 62 | ); |
|---|
| 63 | write_data_in_chars(out); |
|---|
| 64 | out.reset(); |
|---|
| 65 | BOOST_CHECK_MESSAGE( |
|---|
| 66 | compare_files(dest.name(), test.name()), |
|---|
| 67 | "failed writing to filtering_stream<bidirectional> in chars " |
|---|
| 68 | "with large buffer" |
|---|
| 69 | ); |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | { |
|---|
| 73 | temp_file dest; |
|---|
| 74 | temp_file src; // Dummy; |
|---|
| 75 | filtering_stream<bidirectional> out( |
|---|
| 76 | combine(file_source(src.name()), file_sink(dest.name(), out_mode)) |
|---|
| 77 | ); |
|---|
| 78 | write_data_in_chunks(out); |
|---|
| 79 | out.reset(); |
|---|
| 80 | BOOST_CHECK_MESSAGE( |
|---|
| 81 | compare_files(dest.name(), test.name()), |
|---|
| 82 | "failed writing to filtering_stream<bidirectional> in chunks " |
|---|
| 83 | "with large buffer" |
|---|
| 84 | ); |
|---|
| 85 | } |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_BIDIRECTIONAL_HPP_INCLUDED |
|---|