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
6// See http://www.boost.org/libs/iostreams for documentation.
7
8#ifndef BOOST_IOSTREAMS_TEST_READ_SEEKABLE_SEQUENCE_HPP_INCLUDED
9#define BOOST_IOSTREAMS_TEST_READ_SEEKABLE_SEQUENCE_HPP_INCLUDED
10
11#include <fstream>
12#include <boost/iostreams/device/file.hpp>
13#include <boost/iostreams/filtering_stream.hpp>
14#include <boost/range/iterator_range.hpp>
15#include <boost/test/test_tools.hpp>
16#include "detail/sequence.hpp"
17#include "detail/temp_file.hpp"
18#include "detail/verification.hpp"
19
20void read_seekable_sequence_test()
21{
22 using namespace std;
23 using namespace boost;
24 using namespace boost::iostreams;
25 using namespace boost::iostreams::test;
26
27 test_file file;
28 test_sequence<> seq;
29
30 {
31 filtering_stream<seekable> first(make_iterator_range(r&: seq), 0);
32 ifstream second(file.name().c_str());
33 BOOST_CHECK_MESSAGE(
34 compare_streams_in_chars(first, second),
35 "failed reading from filtering_stream<seekable> based on a"
36 "sequence in chars with no buffer"
37 );
38 }
39
40 {
41 filtering_stream<seekable> first(make_iterator_range(r&: seq), 0);
42 ifstream second(file.name().c_str());
43 BOOST_CHECK_MESSAGE(
44 compare_streams_in_chunks(first, second),
45 "failed reading from filtering_stream<seekable> based on a"
46 "sequence in chunks with no buffer"
47 );
48 }
49
50 {
51 filtering_stream<seekable> first(make_iterator_range(r&: seq));
52 ifstream second(file.name().c_str());
53 BOOST_CHECK_MESSAGE(
54 compare_streams_in_chars(first, second),
55 "failed reading from filtering_stream<seekable> based on a"
56 "sequence in chars with large buffer"
57 );
58 }
59
60 {
61 filtering_stream<seekable> first(make_iterator_range(r&: seq));
62 ifstream second(file.name().c_str());
63 BOOST_CHECK_MESSAGE(
64 compare_streams_in_chunks(first, second),
65 "failed reading from filtering_stream<seekable> based on a"
66 "sequence in chunks with large buffer"
67 );
68 }
69}
70
71#endif // #ifndef BOOST_IOSTREAMS_TEST_READ_SEEKABLE_SEQUENCE_HPP_INCLUDED
72

source code of boost/libs/iostreams/test/read_seekable_seq_test.hpp