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