]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/iostreams/test/write_bidir_streambuf_test.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / iostreams / test / write_bidir_streambuf_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_WRITE_BIDIRECTIONAL_STREAMBUF_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_TEST_WRITE_BIDIRECTIONAL_STREAMBUF_HPP_INCLUDED
10
11 #include <fstream>
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_bidirectional_streambuf_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
26 {
27 temp_file test2;
28 {
29 filebuf dest;
30 dest.open(test2.name().c_str(), out_mode);
31 filtering_stream<bidirectional> out(dest, 0);
32 write_data_in_chars(out);
33 }
34 BOOST_CHECK_MESSAGE(
35 compare_files(test2.name(), test.name()),
36 "failed writing to filtering_stream<bidirectional> based "
37 "on a streambuf in chars with no buffer"
38 );
39 }
40
41 {
42 temp_file test2;
43 {
44 filebuf dest;
45 dest.open(test2.name().c_str(), out_mode);
46 filtering_stream<bidirectional> out(dest, 0);
47 write_data_in_chunks(out);
48 }
49 BOOST_CHECK_MESSAGE(
50 compare_files(test2.name(), test.name()),
51 "failed writing to filtering_stream<bidirectional> based "
52 "on a streambuf in chunks with no buffer"
53 );
54 }
55
56 {
57 temp_file test2;
58 {
59 filebuf dest;
60 dest.open(test2.name().c_str(), out_mode);
61 filtering_stream<bidirectional> out(dest);
62 write_data_in_chars(out);
63 }
64 BOOST_CHECK_MESSAGE(
65 compare_files(test2.name(), test.name()),
66 "failed writing to filtering_stream<bidirectional> based "
67 "on a streambuf in chars with large buffer"
68 );
69 }
70
71 {
72 temp_file test2;
73 {
74 filebuf dest;
75 dest.open(test2.name().c_str(), out_mode);
76 filtering_stream<bidirectional> out(dest);
77 write_data_in_chunks(out);
78 }
79 BOOST_CHECK_MESSAGE(
80 compare_files(test2.name(), test.name()),
81 "failed writing to filtering_stream<bidirectional> based "
82 "on a streambuf in chunks with large buffer"
83 );
84 }
85 }
86
87 #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_BIDIRECTIONAL_STREAMBUF_HPP_INCLUDED