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_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_TEST_READ_INPUT_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_input_test()18 void read_input_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_istream first(file_source(test1.name()), 0);
30 ifstream second(test2.name().c_str());
31 BOOST_CHECK_MESSAGE(
32 compare_streams_in_chars(first, second),
33 "failed reading from filtering_istream in chars with no buffer"
34 );
35 }
36
37 {
38 filtering_istream first(file_source(test1.name()), 0);
39 ifstream second(test2.name().c_str());
40 BOOST_CHECK_MESSAGE(
41 compare_streams_in_chunks(first, second),
42 "failed reading from filtering_istream in chunks with no buffer"
43 );
44 }
45
46 {
47 filtering_istream first(file_source(test1.name()));
48 ifstream second(test2.name().c_str());
49 BOOST_CHECK_MESSAGE(
50 compare_streams_in_chars(first, second),
51 "failed reading from filtering_istream in chars with buffer"
52 );
53 }
54
55 {
56 filtering_istream first(file_source(test1.name()));
57 ifstream second(test2.name().c_str());
58 BOOST_CHECK_MESSAGE(
59 compare_streams_in_chunks(first, second),
60 "failed reading from filtering_istream in chunks with buffer"
61 );
62 }
63 }
64
65 #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_HPP_INCLUDED
66