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_INPUT_SEQUENCE_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_TEST_READ_INPUT_SEQUENCE_HPP_INCLUDED
10 
11 #include <fstream>
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 
read_input_sequence_test()19 void read_input_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<input> 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 range_adapter "
35             "in chars with no buffer"
36         );
37     }
38 
39     {
40         filtering_stream<input> 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 range_adapter "
45             "in chars with no buffer"
46         );
47     }
48 
49     {
50         filtering_stream<input> 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 range_adapter "
55             "in chars with large buffer"
56         );
57     }
58 
59     {
60         filtering_stream<input> 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 range_adapter "
65             "in chars with large buffer"
66         );
67     }
68 }
69 
70 #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_SEQUENCE_HPP_INCLUDED
71