Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / iostreams / test / read_bidir_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_BIDIRECTIONAL_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_TEST_READ_BIDIRECTIONAL_HPP_INCLUDED
10
11 #include <fstream>
12 #include <boost/iostreams/combine.hpp>
13 #include <boost/iostreams/device/file.hpp>
14 #include <boost/iostreams/filtering_stream.hpp>
15 #include <boost/test/test_tools.hpp>
16 #include "detail/temp_file.hpp"
17 #include "detail/verification.hpp"
18
19 void read_bidirectional_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 test;          
27
28     {
29         test_file src;
30         temp_file dest; // Dummy.
31         filtering_stream<bidirectional> first(
32             combine(file_source(src.name()), file_sink(dest.name())), 0
33         );
34         ifstream second(test.name().c_str());
35         BOOST_CHECK_MESSAGE(
36             compare_streams_in_chars(first, second),
37             "failed reading from filtering_stream<bidirectional>"
38             "in chars with no buffer"
39         );
40     }
41
42     {
43         test_file src;
44         temp_file dest; // Dummy.
45         filtering_stream<bidirectional> first(
46             combine(file_source(src.name()), file_sink(dest.name())), 0
47         );
48         ifstream second(test.name().c_str());
49         BOOST_CHECK_MESSAGE(
50             compare_streams_in_chunks(first, second),
51             "failed reading from filtering_stream<bidirectional>"
52             "in chunks with no buffer"
53         );
54     }
55
56     {
57         test_file src;
58         temp_file dest; // Dummy.
59         filtering_stream<bidirectional> first(
60             combine(file_source(src.name()), file_sink(dest.name()))
61         );
62         ifstream second(test.name().c_str());
63         BOOST_CHECK_MESSAGE(
64             compare_streams_in_chars(first, second),
65             "failed reading from filtering_stream<bidirectional>"
66             "in chars with large buffer"
67         );
68     }
69
70     {
71         test_file src;
72         temp_file dest; // Dummy.
73         filtering_stream<bidirectional> first(
74             combine(file_source(src.name()), file_sink(dest.name()))
75         );
76         ifstream second(test.name().c_str());
77         BOOST_CHECK_MESSAGE(
78             compare_streams_in_chunks(first, second),
79             "failed reading from filtering_stream<bidirectional>"
80             "in chunks with large buffer"
81         );
82     }
83 }
84
85 #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_BIDIRECTIONAL_HPP_INCLUDED