]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/iostreams/test/seekable_filter_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.
9 #include <boost/config.hpp>
10 #include <boost/detail/workaround.hpp>
11 #include <boost/iostreams/device/array.hpp>
12 #include <boost/iostreams/device/array.hpp>
13 #include <boost/iostreams/filtering_stream.hpp>
14 #include <boost/test/test_tools.hpp>
15 #include <boost/test/unit_test.hpp>
16 #include "../example/container_device.hpp" // We use container_device instead
17 #include "detail/filters.hpp" // of make_iterator_range to
18 #include "detail/temp_file.hpp" // reduce dependence on Boost.Range
19 #include "detail/verification.hpp"
23 using namespace boost
;
24 using namespace boost::iostreams
;
25 using namespace boost::iostreams::example
;
26 using namespace boost::iostreams::test
;
27 using boost::unit_test::test_suite
;
30 // Code generation bugs cause tests to fail with global optimization.
31 #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
32 # pragma optimize("g", off)
35 void seekable_filter_test()
38 vector
<char> test(data_reps
* data_length(), '0');
39 filtering_stream
<seekable
> io
;
40 io
.push(identity_seekable_filter());
41 io
.push(container_device
< vector
<char> >(test
));
42 io
.exceptions(BOOST_IOS::failbit
| BOOST_IOS::badbit
);
44 test_seekable_in_chars(io
),
45 "failed seeking within a file, in chars"
50 vector
<char> test(data_reps
* data_length(), '0');
51 filtering_stream
<seekable
> io
;
52 io
.push(identity_seekable_filter());
53 io
.push(container_device
< vector
<char> >(test
));
54 io
.exceptions(BOOST_IOS::failbit
| BOOST_IOS::badbit
);
56 test_seekable_in_chunks(io
),
57 "failed seeking within a file, in chunks"
62 vector
<char> test(data_reps
* data_length(), '0');
63 filtering_stream
<seekable
> io
;
64 io
.push(identity_seekable_multichar_filter());
65 io
.push(container_device
< vector
<char> >(test
));
66 io
.exceptions(BOOST_IOS::failbit
| BOOST_IOS::badbit
);
68 test_seekable_in_chars(io
),
69 "failed seeking within a file, in chars"
74 vector
<char> test(data_reps
* data_length(), '0');
75 filtering_stream
<seekable
> io
;
76 io
.push(identity_seekable_multichar_filter());
77 io
.push(container_device
< vector
<char> >(test
));
78 io
.exceptions(BOOST_IOS::failbit
| BOOST_IOS::badbit
);
80 test_seekable_in_chunks(io
),
81 "failed seeking within a file, in chunks"
86 #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
87 # pragma optimize("", on)
90 test_suite
* init_unit_test_suite(int, char* [])
92 test_suite
* test
= BOOST_TEST_SUITE("seekable filter test");
93 test
->add(BOOST_TEST_CASE(&seekable_filter_test
));