read_input_istream_test.hpp 2.3 KB

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