filtering_stream_flush_test.hpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // (C) Copyright 2011 Steven Watanabe
  2. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  4. // See http://www.boost.org/libs/iostreams for documentation.
  5. #include <fstream>
  6. #include <boost/iostreams/filtering_stream.hpp>
  7. #include <boost/test/test_tools.hpp>
  8. #include "detail/sequence.hpp"
  9. #include "detail/temp_file.hpp"
  10. #include "detail/verification.hpp"
  11. void test_filtering_ostream_flush()
  12. {
  13. using namespace std;
  14. using namespace boost;
  15. using namespace boost::iostreams;
  16. using namespace boost::iostreams::test;
  17. lowercase_file lower;
  18. {
  19. temp_file dest;
  20. filtering_ostream out;
  21. out.push(tolower_filter());
  22. out.push(file_sink(dest.name(), out_mode));
  23. write_data_in_chars(out);
  24. out.flush();
  25. BOOST_CHECK_MESSAGE(
  26. compare_files(dest.name(), lower.name()),
  27. "failed writing to a filtering_ostream in chars with an "
  28. "output filter"
  29. );
  30. }
  31. }