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_WRITE_SEEKABLE_HPP_INCLUDED |
9 | #define BOOST_IOSTREAMS_TEST_WRITE_SEEKABLE_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 write_seekable_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 test; |
26 | BOOST_IOS::openmode mode = out_mode | BOOST_IOS::trunc; |
27 | |
28 | { |
29 | temp_file test2; |
30 | filtering_stream<seekable> out(file(test2.name(), mode), 0); |
31 | write_data_in_chars(os&: out); |
32 | out.reset(); |
33 | BOOST_CHECK_MESSAGE( |
34 | compare_files(test2.name(), test.name()), |
35 | "failed writing to filtering_stream<seekable> in chars with" |
36 | "no buffer" |
37 | ); |
38 | } |
39 | |
40 | { |
41 | temp_file test2; |
42 | filtering_stream<seekable> out(file(test2.name(), mode), 0); |
43 | write_data_in_chunks(os&: out); |
44 | out.reset(); |
45 | BOOST_CHECK_MESSAGE( |
46 | compare_files(test2.name(), test.name()), |
47 | "failed writing to filtering_stream<seekable> in chunks with" |
48 | "no buffer" |
49 | ); |
50 | } |
51 | |
52 | { |
53 | temp_file test2; |
54 | filtering_stream<seekable> out(file(test2.name(), mode)); |
55 | write_data_in_chars(os&: out); |
56 | out.reset(); |
57 | BOOST_CHECK_MESSAGE( |
58 | compare_files(test2.name(), test.name()), |
59 | "failed writing to filtering_stream<seekable> in chars with" |
60 | "large buffer" |
61 | ); |
62 | } |
63 | |
64 | { |
65 | temp_file test2; |
66 | filtering_stream<seekable> out(file(test2.name(), mode)); |
67 | write_data_in_chunks(os&: out); |
68 | out.reset(); |
69 | BOOST_CHECK_MESSAGE( |
70 | compare_files(test2.name(), test.name()), |
71 | "failed writing to filtering_stream<seekable> in chunks with" |
72 | "large buffer" |
73 | ); |
74 | } |
75 | } |
76 | |
77 | #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_SEEKABLE_HPP_INCLUDED |
78 | |