1 | // (C) Copyright Jonathan Turkanis 2004 |
---|
2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
---|
3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) |
---|
4 | |
---|
5 | // See http://www.boost.org/libs/iostreams for documentation. |
---|
6 | |
---|
7 | #ifndef BOOST_IOSTREAMS_TEST_WRITE_SEEKABLE_HPP_INCLUDED |
---|
8 | #define BOOST_IOSTREAMS_TEST_WRITE_SEEKABLE_HPP_INCLUDED |
---|
9 | |
---|
10 | #include <fstream> |
---|
11 | #include <boost/iostreams/device/file.hpp> |
---|
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 write_seekable_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 | BOOST_IOS::openmode mode = out_mode | BOOST_IOS::trunc; |
---|
26 | |
---|
27 | { |
---|
28 | temp_file test2; |
---|
29 | filtering_stream<seekable> out(file(test2.name(), mode), 0); |
---|
30 | write_data_in_chars(out); |
---|
31 | out.reset(); |
---|
32 | BOOST_CHECK_MESSAGE( |
---|
33 | compare_files(test2.name(), test.name()), |
---|
34 | "failed writing to filtering_stream<seekable> in chars with" |
---|
35 | "no buffer" |
---|
36 | ); |
---|
37 | } |
---|
38 | |
---|
39 | { |
---|
40 | temp_file test2; |
---|
41 | filtering_stream<seekable> out(file(test2.name(), mode), 0); |
---|
42 | write_data_in_chunks(out); |
---|
43 | out.reset(); |
---|
44 | BOOST_CHECK_MESSAGE( |
---|
45 | compare_files(test2.name(), test.name()), |
---|
46 | "failed writing to filtering_stream<seekable> in chunks with" |
---|
47 | "no buffer" |
---|
48 | ); |
---|
49 | } |
---|
50 | |
---|
51 | { |
---|
52 | temp_file test2; |
---|
53 | filtering_stream<seekable> out(file(test2.name(), mode)); |
---|
54 | write_data_in_chars(out); |
---|
55 | out.reset(); |
---|
56 | BOOST_CHECK_MESSAGE( |
---|
57 | compare_files(test2.name(), test.name()), |
---|
58 | "failed writing to filtering_stream<seekable> in chars with" |
---|
59 | "large buffer" |
---|
60 | ); |
---|
61 | } |
---|
62 | |
---|
63 | { |
---|
64 | temp_file test2; |
---|
65 | filtering_stream<seekable> out(file(test2.name(), mode)); |
---|
66 | write_data_in_chunks(out); |
---|
67 | out.reset(); |
---|
68 | BOOST_CHECK_MESSAGE( |
---|
69 | compare_files(test2.name(), test.name()), |
---|
70 | "failed writing to filtering_stream<seekable> in chunks with" |
---|
71 | "large buffer" |
---|
72 | ); |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_SEEKABLE_HPP_INCLUDED |
---|