read_input_seq_test.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. // See http://www.boost.org/libs/iostreams for documentation.
  6. #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_SEQUENCE_HPP_INCLUDED
  7. #define BOOST_IOSTREAMS_TEST_READ_INPUT_SEQUENCE_HPP_INCLUDED
  8. #include <fstream>
  9. #include <boost/iostreams/filtering_stream.hpp>
  10. #include <boost/range/iterator_range.hpp>
  11. #include <boost/test/test_tools.hpp>
  12. #include "detail/sequence.hpp"
  13. #include "detail/temp_file.hpp"
  14. #include "detail/verification.hpp"
  15. void read_input_sequence_test()
  16. {
  17. using namespace std;
  18. using namespace boost;
  19. using namespace boost::iostreams;
  20. using namespace boost::iostreams::test;
  21. test_file file;
  22. test_sequence<> seq;
  23. {
  24. filtering_stream<input> first(make_iterator_range(seq), 0);
  25. ifstream second(file.name().c_str());
  26. BOOST_CHECK_MESSAGE(
  27. compare_streams_in_chars(first, second),
  28. "failed reading from range_adapter "
  29. "in chars with no buffer"
  30. );
  31. }
  32. {
  33. filtering_stream<input> first(make_iterator_range(seq), 0);
  34. ifstream second(file.name().c_str());
  35. BOOST_CHECK_MESSAGE(
  36. compare_streams_in_chunks(first, second),
  37. "failed reading from range_adapter "
  38. "in chars with no buffer"
  39. );
  40. }
  41. {
  42. filtering_stream<input> first(make_iterator_range(seq));
  43. ifstream second(file.name().c_str());
  44. BOOST_CHECK_MESSAGE(
  45. compare_streams_in_chars(first, second),
  46. "failed reading from range_adapter "
  47. "in chars with large buffer"
  48. );
  49. }
  50. {
  51. filtering_stream<input> first(make_iterator_range(seq));
  52. ifstream second(file.name().c_str());
  53. BOOST_CHECK_MESSAGE(
  54. compare_streams_in_chunks(first, second),
  55. "failed reading from range_adapter "
  56. "in chars with large buffer"
  57. );
  58. }
  59. }
  60. #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_SEQUENCE_HPP_INCLUDED