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_ISTREAM_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_TEST_READ_INPUT_ISTREAM_HPP_INCLUDED
10 
11 #include <fstream>
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 
read_input_istream_test()17 void read_input_istream_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 test;
25     test_file test2;
26 
27     {
28         test_file test2;
29         ifstream src(test2.name().c_str());
30         filtering_istream first(src, 0);
31         ifstream second(test.name().c_str());
32         BOOST_CHECK_MESSAGE(
33             compare_streams_in_chars(first, second),
34             "failed reading from filtering_istream based on an istream"
35             "in chars with no buffer"
36         );
37     }
38 
39     {
40         test_file test2;
41         ifstream src(test2.name().c_str());
42         filtering_istream first(src, 0);
43         ifstream second(test.name().c_str());
44         BOOST_CHECK_MESSAGE(
45             compare_streams_in_chunks(first, second),
46             "failed reading from filtering_istream based on an istream"
47             "in chunks with no buffer"
48         );
49     }
50 
51     {
52         test_file test2;
53         ifstream src(test2.name().c_str());
54         filtering_istream first(src);
55         ifstream second(test.name().c_str());
56         BOOST_CHECK_MESSAGE(
57             compare_streams_in_chars(first, second),
58             "failed reading from filtering_istream based on an istream"
59             "in chars with large buffer"
60         );
61     }
62 
63     {
64         test_file test2;
65         ifstream src(test2.name().c_str());
66         filtering_istream first(src);
67         ifstream second(test.name().c_str());
68         BOOST_CHECK_MESSAGE(
69             compare_streams_in_chunks(first, second),
70             "failed reading from filtering_istream based on an istream"
71             "in chunks with large buffer"
72         );
73     }
74 }
75 
76 #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_ISTREAM_HPP_INCLUDED
77