read_bidir_filter_test.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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_BIDIRECTIONAL_FILTER_HPP_INCLUDED
  7. #define BOOST_IOSTREAMS_TEST_READ_BIDIRECTIONAL_FILTER_HPP_INCLUDED
  8. #include <fstream>
  9. #include <boost/iostreams/combine.hpp>
  10. #include <boost/iostreams/device/file.hpp>
  11. #include <boost/iostreams/filtering_stream.hpp>
  12. #include <boost/test/test_tools.hpp>
  13. #include "detail/filters.hpp"
  14. #include "detail/sequence.hpp"
  15. #include "detail/temp_file.hpp"
  16. #include "detail/verification.hpp"
  17. void read_bidirectional_filter_test()
  18. {
  19. using namespace std;
  20. using namespace boost;
  21. using namespace boost::iostreams;
  22. using namespace boost::iostreams::test;
  23. uppercase_file upper;
  24. //{
  25. // test_file src;
  26. // temp_file dest; // Dummy.
  27. // filtering_stream<bidirectional> first;
  28. // first.push(combine(toupper_filter(), tolower_filter()));
  29. // first.push(
  30. // combine(file_source(src.name()), file_sink(dest.name()))
  31. // );
  32. // ifstream second(upper.name().c_str());
  33. // BOOST_CHECK_MESSAGE(
  34. // compare_streams_in_chars(first, second),
  35. // "failed reading from filtering_stream<bidirectional> in chars with an "
  36. // "input filter"
  37. // );
  38. //}
  39. {
  40. test_file src;
  41. temp_file dest; // Dummy.
  42. filtering_stream<bidirectional> first;
  43. first.push(combine(toupper_filter(), tolower_filter()));
  44. first.push(
  45. combine(file_source(src.name()), file_sink(dest.name()))
  46. );
  47. ifstream second(upper.name().c_str());
  48. BOOST_CHECK_MESSAGE(
  49. compare_streams_in_chunks(first, second),
  50. "failed reading from filtering_stream<bidirectional> in chunks with an "
  51. "input filter"
  52. );
  53. }
  54. //{
  55. // test_file src;
  56. // temp_file dest; // Dummy.
  57. // filtering_stream<bidirectional> first(
  58. // combine(toupper_multichar_filter(), tolower_filter()), 0
  59. // );
  60. // first.push(
  61. // combine(file_source(src.name()), file_sink(dest.name()))
  62. // );
  63. // ifstream second(upper.name().c_str());
  64. // BOOST_CHECK_MESSAGE(
  65. // compare_streams_in_chars(first, second),
  66. // "failed reading from filtering_stream<bidirectional> in chars with "
  67. // "a multichar input filter with no buffer"
  68. // );
  69. //}
  70. //{
  71. // test_file src;
  72. // temp_file dest; // Dummy.
  73. // filtering_stream<bidirectional> first(
  74. // combine(toupper_multichar_filter(), tolower_filter()), 0
  75. // );
  76. // first.push(
  77. // combine(file_source(src.name()), file_sink(dest.name()))
  78. // );
  79. // ifstream second(upper.name().c_str());
  80. // BOOST_CHECK_MESSAGE(
  81. // compare_streams_in_chunks(first, second),
  82. // "failed reading from filtering_stream<bidirectional> in chunks "
  83. // "with a multichar input filter with no buffer"
  84. // );
  85. //}
  86. //{
  87. // test_file src;
  88. // temp_file dest; // Dummy.
  89. // filtering_stream<bidirectional> first(
  90. // combine(toupper_multichar_filter(), tolower_filter())
  91. // );
  92. // first.push(
  93. // combine(file_source(src.name()), file_sink(dest.name()))
  94. // );
  95. // ifstream second(upper.name().c_str());
  96. // BOOST_CHECK_MESSAGE(
  97. // compare_streams_in_chars(first, second),
  98. // "failed reading from filtering_stream<bidirectional> in chars with a "
  99. // "multichar input filter"
  100. // );
  101. //}
  102. //{
  103. // test_file src;
  104. // temp_file dest; // Dummy.
  105. // filtering_stream<bidirectional> first(
  106. // combine(toupper_multichar_filter(), tolower_filter())
  107. // );
  108. // first.push(
  109. // combine(file_source(src.name()), file_sink(dest.name()))
  110. // );
  111. // ifstream second(upper.name().c_str());
  112. // BOOST_CHECK_MESSAGE(
  113. // compare_streams_in_chunks(first, second),
  114. // "failed reading from filtering_stream<bidirectional> in chunks "
  115. // "with a multichar input filter"
  116. // );
  117. //}
  118. }
  119. #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_BIDIRECTIONAL_FILTER_HPP_INCLUDED