read_seekable_seq_test.hpp 2.5 KB

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