Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / iostreams / test / read_input_istream_test.hpp
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
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
26     {
27         test_file test2;
28         ifstream src(test2.name().c_str());
29         filtering_istream first(src, 0);
30         ifstream second(test.name().c_str());
31         BOOST_CHECK_MESSAGE(
32             compare_streams_in_chars(first, second),
33             "failed reading from filtering_istream based on an istream"
34             "in chars with no buffer"
35         );
36     }
37
38     {
39         test_file test2;
40         ifstream src(test2.name().c_str());
41         filtering_istream first(src, 0);
42         ifstream second(test.name().c_str());
43         BOOST_CHECK_MESSAGE(
44             compare_streams_in_chunks(first, second),
45             "failed reading from filtering_istream based on an istream"
46             "in chunks with no buffer"
47         );
48     }
49
50     {
51         test_file test2;
52         ifstream src(test2.name().c_str());
53         filtering_istream first(src);
54         ifstream second(test.name().c_str());
55         BOOST_CHECK_MESSAGE(
56             compare_streams_in_chars(first, second),
57             "failed reading from filtering_istream based on an istream"
58             "in chars with large buffer"
59         );
60     }
61
62     {
63         test_file test2;
64         ifstream src(test2.name().c_str());
65         filtering_istream first(src);
66         ifstream second(test.name().c_str());
67         BOOST_CHECK_MESSAGE(
68             compare_streams_in_chunks(first, second),
69             "failed reading from filtering_istream based on an istream"
70             "in chunks with large buffer"
71         );
72     }
73 }
74
75 #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_ISTREAM_HPP_INCLUDED