]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/iostreams/test/flush_test.cpp
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.)
6 // See http://www.boost.org/libs/iostreams for documentation.
8 #include <algorithm> // equal.
10 #include <boost/iostreams/device/back_inserter.hpp>
11 #include <boost/iostreams/device/file.hpp>
12 #include <boost/iostreams/device/null.hpp>
13 #include <boost/iostreams/filtering_stream.hpp>
14 #include <boost/iostreams/stream.hpp>
15 #include <boost/iostreams/operations.hpp>
16 #include <boost/test/test_tools.hpp>
17 #include <boost/test/unit_test.hpp>
18 #include "detail/filters.hpp"
19 #include "detail/temp_file.hpp"
20 #include "detail/verification.hpp"
23 using namespace boost
;
24 using namespace boost::iostreams
;
25 using namespace boost::iostreams::test
;
26 using boost::unit_test::test_suite
;
31 stream_buffer
<null_sink
> null
;
32 null
.open(null_sink());
34 iostreams::flush(null
),
35 "failed flushing stream_buffer"
39 "failed strict-syncing stream_buffer with "
40 "non-flushable resource"
45 stream
<null_sink
> null
;
46 null
.open(null_sink());
48 iostreams::flush(null
),
49 "failed flushing stream"
53 "failed strict-syncing stream with "
54 "non-flushable resource"
59 filtering_ostream null
;
60 null
.push(null_sink());
62 iostreams::flush(null
),
63 "failed flushing filtering_ostream"
67 "failed strict-syncing filtering_ostream with "
68 "non-flushable resource"
73 filtering_ostream null
;
74 null
.push(tolower_filter());
75 null
.push(null_sink());
77 iostreams::flush(null
),
78 "failed flushing filtering_ostream with non-flushable filter"
82 "strict-syncing filtering_ostream with "
83 "non-flushable filter succeeded"
90 filtering_ostream out
;
91 out
.set_auto_close(false);
92 out
.push(flushable_output_filter());
95 out
.push(iostreams::back_inserter(dest1
));
96 write_data_in_chunks(out
);
101 out
.push(iostreams::back_inserter(dest2
));
102 write_data_in_chunks(out
);
106 dest1
.size() == dest2
.size() &&
107 std::equal(dest1
.begin(), dest1
.end(), dest2
.begin()),
108 "failed flush filtering_ostream with auto_close disabled"
115 filtering_ostream out
;
116 out
.set_auto_close(false);
117 out
.push(flushable_output_filter());
118 out
.push(flushable_output_filter());
121 out
.push(iostreams::back_inserter(dest1
));
122 write_data_in_chunks(out
);
127 out
.push(iostreams::back_inserter(dest2
));
128 write_data_in_chunks(out
);
132 dest1
.size() == dest2
.size() &&
133 std::equal(dest1
.begin(), dest1
.end(), dest2
.begin()),
134 "failed flush filtering_ostream with two flushable filters "
135 "with auto_close disabled"
140 test_suite
* init_unit_test_suite(int, char* [])
142 test_suite
* test
= BOOST_TEST_SUITE("flush test");
143 test
->add(BOOST_TEST_CASE(&flush_test
));