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_STREAMBUF_HPP_INCLUDED |
9 | #define BOOST_IOSTREAMS_TEST_READ_BIDIRECTIONAL_STREAMBUF_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 | |
18 | void read_bidirectional_streambuf_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 | filebuf fb; |
30 | fb.open(s: test1.name().c_str(), BOOST_IOS::in); |
31 | filtering_stream<bidirectional> first(fb, 0); |
32 | ifstream second(test2.name().c_str()); |
33 | BOOST_CHECK_MESSAGE( |
34 | compare_streams_in_chars(first, second), |
35 | "failed reading from filtering_stream<bidirectional> based on a" |
36 | "streambuf in chars with no buffer" |
37 | ); |
38 | } |
39 | |
40 | { |
41 | filebuf fb; |
42 | fb.open(s: test1.name().c_str(), BOOST_IOS::in); |
43 | filtering_stream<bidirectional> first(fb, 0); |
44 | ifstream second(test2.name().c_str()); |
45 | BOOST_CHECK_MESSAGE( |
46 | compare_streams_in_chunks(first, second), |
47 | "failed reading from filtering_stream<bidirectional> based on a" |
48 | "streambuf in chunks with no buffer" |
49 | ); |
50 | } |
51 | |
52 | { |
53 | filebuf fb; |
54 | fb.open(s: test1.name().c_str(), BOOST_IOS::in); |
55 | filtering_stream<bidirectional> first(fb); |
56 | ifstream second(test2.name().c_str()); |
57 | BOOST_CHECK_MESSAGE( |
58 | compare_streams_in_chars(first, second), |
59 | "failed reading from filtering_stream<bidirectional> based on a" |
60 | "streambuf in chars with large buffer" |
61 | ); |
62 | } |
63 | |
64 | { |
65 | filebuf fb; |
66 | fb.open(s: test1.name().c_str(), BOOST_IOS::in); |
67 | filtering_stream<bidirectional> first(fb); |
68 | ifstream second(test2.name().c_str()); |
69 | BOOST_CHECK_MESSAGE( |
70 | compare_streams_in_chunks(first, second), |
71 | "failed reading from filtering_stream<bidirectional> based on a" |
72 | "streambuf in chunks with large buffer" |
73 | ); |
74 | } |
75 | } |
76 | |
77 | #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_BIDIRECTIONAL_STREAMBUF_HPP_INCLUDED |
78 | |