read_seekable_test.hpp 2.2 KB

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