read_input_test.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_HPP_INCLUDED
  7. #define BOOST_IOSTREAMS_TEST_READ_INPUT_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_input_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_istream first(file_source(test1.name()), 0);
  24. ifstream second(test2.name().c_str());
  25. BOOST_CHECK_MESSAGE(
  26. compare_streams_in_chars(first, second),
  27. "failed reading from filtering_istream in chars with no buffer"
  28. );
  29. }
  30. {
  31. filtering_istream first(file_source(test1.name()), 0);
  32. ifstream second(test2.name().c_str());
  33. BOOST_CHECK_MESSAGE(
  34. compare_streams_in_chunks(first, second),
  35. "failed reading from filtering_istream in chunks with no buffer"
  36. );
  37. }
  38. {
  39. filtering_istream first(file_source(test1.name()));
  40. ifstream second(test2.name().c_str());
  41. BOOST_CHECK_MESSAGE(
  42. compare_streams_in_chars(first, second),
  43. "failed reading from filtering_istream in chars with buffer"
  44. );
  45. }
  46. {
  47. filtering_istream first(file_source(test1.name()));
  48. ifstream second(test2.name().c_str());
  49. BOOST_CHECK_MESSAGE(
  50. compare_streams_in_chunks(first, second),
  51. "failed reading from filtering_istream in chunks with buffer"
  52. );
  53. }
  54. }
  55. #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_HPP_INCLUDED