seek_test.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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_SEEK_HPP_INCLUDED
  7. #define BOOST_IOSTREAMS_TEST_SEEK_HPP_INCLUDED
  8. #include <boost/config.hpp> // BOOST_MSVC, make sure size_t is in std.
  9. #include <cstddef> // std::size_t.
  10. #include <string>
  11. #include <boost/iostreams/device/array.hpp>
  12. #include <boost/iostreams/filtering_stream.hpp>
  13. #include <boost/test/test_tools.hpp>
  14. #include "../example/container_device.hpp" // We use container_device instead
  15. #include "detail/verification.hpp" // of make_iterator_range to
  16. // reduce dependence on Boost.Range
  17. void seek_test()
  18. {
  19. using namespace std;
  20. using namespace boost;
  21. using namespace boost::iostreams;
  22. using namespace boost::iostreams::example;
  23. using namespace boost::iostreams::test;
  24. {
  25. string test(data_reps * data_length(), '\0');
  26. filtering_stream<seekable> io;
  27. io.push(container_device<string>(test));
  28. BOOST_CHECK_MESSAGE(
  29. test_seekable_in_chars(io),
  30. "failed seeking within a filtering_stream<seekable>, in chars"
  31. );
  32. }
  33. {
  34. string test(data_reps * data_length(), '\0');
  35. filtering_stream<seekable> io;
  36. io.push(container_device<string>(test));
  37. BOOST_CHECK_MESSAGE(
  38. test_seekable_in_chunks(io),
  39. "failed seeking within a filtering_stream<seekable>, in chunks"
  40. );
  41. }
  42. }
  43. #endif // #ifndef BOOST_IOSTREAMS_TEST_SEEK_HPP_INCLUDED