[29] | 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_SEEKABLE_HPP_INCLUDED |
---|
| 8 | #define BOOST_IOSTREAMS_TEST_READ_SEEKABLE_HPP_INCLUDED |
---|
| 9 | |
---|
| 10 | #include <fstream> |
---|
| 11 | #include <boost/iostreams/device/file.hpp> |
---|
| 12 | #include <boost/iostreams/filtering_stream.hpp> |
---|
| 13 | #include <boost/test/test_tools.hpp> |
---|
| 14 | #include "detail/temp_file.hpp" |
---|
| 15 | #include "detail/verification.hpp" |
---|
| 16 | |
---|
| 17 | void read_seekable_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 test1; |
---|
| 25 | test_file test2; |
---|
| 26 | |
---|
| 27 | { |
---|
| 28 | filtering_stream<seekable> first(file(test1.name(), in_mode), 0); |
---|
| 29 | ifstream second(test2.name().c_str(), in_mode); |
---|
| 30 | BOOST_CHECK_MESSAGE( |
---|
| 31 | compare_streams_in_chars(first, second), |
---|
| 32 | "failed reading from filtering_stream<seekable>" |
---|
| 33 | "in chars with no buffer" |
---|
| 34 | ); |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | { |
---|
| 38 | filtering_stream<seekable> first(file(test1.name(), in_mode), 0); |
---|
| 39 | ifstream second(test2.name().c_str(), in_mode); |
---|
| 40 | BOOST_CHECK_MESSAGE( |
---|
| 41 | compare_streams_in_chunks(first, second), |
---|
| 42 | "failed reading from filtering_stream<seekable>" |
---|
| 43 | "in chars with no buffer" |
---|
| 44 | ); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | { |
---|
| 48 | filtering_stream<seekable> first(file(test1.name(), in_mode)); |
---|
| 49 | ifstream second(test2.name().c_str(), in_mode); |
---|
| 50 | BOOST_CHECK_MESSAGE( |
---|
| 51 | compare_streams_in_chars(first, second), |
---|
| 52 | "failed reading from filtering_stream<seekable>" |
---|
| 53 | "in chars with large buffer" |
---|
| 54 | ); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | { |
---|
| 58 | filtering_stream<seekable> first(file(test1.name(), in_mode)); |
---|
| 59 | ifstream second(test2.name().c_str(), in_mode); |
---|
| 60 | BOOST_CHECK_MESSAGE( |
---|
| 61 | compare_streams_in_chunks(first, second), |
---|
| 62 | "failed reading from filtering_stream<seekable>" |
---|
| 63 | "in chars with large buffer" |
---|
| 64 | ); |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_SEEKABLE_HPP_INCLUDED |
---|