]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | #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" | |
17 | ||
18 | using namespace boost::iostreams; | |
19 | using namespace boost::iostreams::test; | |
20 | using boost::unit_test::test_suite; | |
21 | namespace io = boost::iostreams; | |
22 | ||
23 | void read_write_test() | |
24 | { | |
25 | ||
26 | test_file test; | |
27 | lowercase_file lower; | |
28 | uppercase_file upper; | |
29 | ||
30 | BOOST_CHECK( test_input_filter( | |
31 | invert(tolower_filter()), | |
32 | file_source(test.name(), in_mode), | |
33 | file_source(lower.name(), in_mode) ) ); | |
34 | ||
35 | BOOST_CHECK( test_output_filter( | |
36 | invert(toupper_filter()), | |
37 | file_source(test.name(), in_mode), | |
38 | file_source(upper.name(), in_mode) ) ); | |
39 | } | |
40 | ||
41 | void close_test() | |
42 | { | |
43 | // Invert an output filter | |
44 | { | |
45 | operation_sequence seq; | |
46 | chain<input> ch; | |
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); | |
51 | } | |
52 | ||
53 | // Invert an input filter | |
54 | { | |
55 | operation_sequence seq; | |
56 | chain<output> ch; | |
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); | |
61 | } | |
62 | } | |
63 | ||
64 | test_suite* init_unit_test_suite(int, char* []) | |
65 | { | |
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)); | |
69 | return test; | |
70 | } |