]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/iostreams/test/invert_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 <boost/iostreams/device/file.hpp>
9 #include <boost/iostreams/filter/test.hpp>
10 #include <boost/iostreams/invert.hpp>
11 #include <boost/test/test_tools.hpp>
12 #include <boost/test/unit_test.hpp>
13 #include "detail/closable.hpp"
14 #include "detail/filters.hpp"
15 #include "detail/operation_sequence.hpp"
16 #include "detail/temp_file.hpp"
18 using namespace boost::iostreams
;
19 using namespace boost::iostreams::test
;
20 using boost::unit_test::test_suite
;
21 namespace io
= boost::iostreams
;
23 void read_write_test()
30 BOOST_CHECK( test_input_filter(
31 invert(tolower_filter()),
32 file_source(test
.name(), in_mode
),
33 file_source(lower
.name(), in_mode
) ) );
35 BOOST_CHECK( test_output_filter(
36 invert(toupper_filter()),
37 file_source(test
.name(), in_mode
),
38 file_source(upper
.name(), in_mode
) ) );
43 // Invert an output filter
45 operation_sequence seq
;
47 ch
.push(io::invert(closable_filter
<output
>(seq
.new_operation(2))));
48 ch
.push(closable_device
<input
>(seq
.new_operation(1)));
49 BOOST_CHECK_NO_THROW(ch
.reset());
50 BOOST_CHECK_OPERATION_SEQUENCE(seq
);
53 // Invert an input filter
55 operation_sequence seq
;
57 ch
.push(io::invert(closable_filter
<input
>(seq
.new_operation(1))));
58 ch
.push(closable_device
<output
>(seq
.new_operation(2)));
59 BOOST_CHECK_NO_THROW(ch
.reset());
60 BOOST_CHECK_OPERATION_SEQUENCE(seq
);
64 test_suite
* init_unit_test_suite(int, char* [])
66 test_suite
* test
= BOOST_TEST_SUITE("reverse test");
67 test
->add(BOOST_TEST_CASE(&read_write_test
));
68 test
->add(BOOST_TEST_CASE(&close_test
));