[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_SEQUENCE_HPP_INCLUDED |
---|
| 8 | #define BOOST_IOSTREAMS_TEST_READ_SEEKABLE_SEQUENCE_HPP_INCLUDED |
---|
| 9 | |
---|
| 10 | #include <fstream> |
---|
| 11 | #include <boost/iostreams/device/file.hpp> |
---|
| 12 | #include <boost/iostreams/filtering_stream.hpp> |
---|
| 13 | #include <boost/range/iterator_range.hpp> |
---|
| 14 | #include <boost/test/test_tools.hpp> |
---|
| 15 | #include "detail/sequence.hpp" |
---|
| 16 | #include "detail/temp_file.hpp" |
---|
| 17 | #include "detail/verification.hpp" |
---|
| 18 | |
---|
| 19 | void read_seekable_sequence_test() |
---|
| 20 | { |
---|
| 21 | using namespace std; |
---|
| 22 | using namespace boost; |
---|
| 23 | using namespace boost::iostreams; |
---|
| 24 | using namespace boost::iostreams::test; |
---|
| 25 | |
---|
| 26 | test_file file; |
---|
| 27 | test_sequence<> seq; |
---|
| 28 | |
---|
| 29 | { |
---|
| 30 | filtering_stream<seekable> first(make_iterator_range(seq), 0); |
---|
| 31 | ifstream second(file.name().c_str()); |
---|
| 32 | BOOST_CHECK_MESSAGE( |
---|
| 33 | compare_streams_in_chars(first, second), |
---|
| 34 | "failed reading from filtering_stream<seekable> based on a" |
---|
| 35 | "sequence in chars with no buffer" |
---|
| 36 | ); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | { |
---|
| 40 | filtering_stream<seekable> first(make_iterator_range(seq), 0); |
---|
| 41 | ifstream second(file.name().c_str()); |
---|
| 42 | BOOST_CHECK_MESSAGE( |
---|
| 43 | compare_streams_in_chunks(first, second), |
---|
| 44 | "failed reading from filtering_stream<seekable> based on a" |
---|
| 45 | "sequence in chunks with no buffer" |
---|
| 46 | ); |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | { |
---|
| 50 | filtering_stream<seekable> first(make_iterator_range(seq)); |
---|
| 51 | ifstream second(file.name().c_str()); |
---|
| 52 | BOOST_CHECK_MESSAGE( |
---|
| 53 | compare_streams_in_chars(first, second), |
---|
| 54 | "failed reading from filtering_stream<seekable> based on a" |
---|
| 55 | "sequence in chars with large buffer" |
---|
| 56 | ); |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | { |
---|
| 60 | filtering_stream<seekable> first(make_iterator_range(seq)); |
---|
| 61 | ifstream second(file.name().c_str()); |
---|
| 62 | BOOST_CHECK_MESSAGE( |
---|
| 63 | compare_streams_in_chunks(first, second), |
---|
| 64 | "failed reading from filtering_stream<seekable> based on a" |
---|
| 65 | "sequence in chunks with large buffer" |
---|
| 66 | ); |
---|
| 67 | } |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_SEEKABLE_SEQUENCE_HPP_INCLUDED |
---|