// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) // (C) Copyright 2004-2007 Jonathan Turkanis // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) // See http://www.boost.org/libs/iostreams for documentation. #include #include #include #include #include #include "detail/closable.hpp" #include "detail/filters.hpp" #include "detail/operation_sequence.hpp" #include "detail/temp_file.hpp" using namespace boost::iostreams; using namespace boost::iostreams::test; using boost::unit_test::test_suite; namespace io = boost::iostreams; void read_write_test() { test_file test; lowercase_file lower; uppercase_file upper; BOOST_CHECK( test_input_filter( invert(tolower_filter()), file_source(test.name(), in_mode), file_source(lower.name(), in_mode) ) ); BOOST_CHECK( test_output_filter( invert(toupper_filter()), file_source(test.name(), in_mode), file_source(upper.name(), in_mode) ) ); } void close_test() { // Invert an output filter { operation_sequence seq; chain ch; ch.push(io::invert(closable_filter(seq.new_operation(2)))); ch.push(closable_device(seq.new_operation(1))); BOOST_CHECK_NO_THROW(ch.reset()); BOOST_CHECK_OPERATION_SEQUENCE(seq); } // Invert an input filter { operation_sequence seq; chain ch; ch.push(io::invert(closable_filter(seq.new_operation(1)))); ch.push(closable_device(seq.new_operation(2))); BOOST_CHECK_NO_THROW(ch.reset()); BOOST_CHECK_OPERATION_SEQUENCE(seq); } } test_suite* init_unit_test_suite(int, char* []) { test_suite* test = BOOST_TEST_SUITE("reverse test"); test->add(BOOST_TEST_CASE(&read_write_test)); test->add(BOOST_TEST_CASE(&close_test)); return test; }