]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_WRITE_OUTPUT_ITERATOR_HPP_INCLUDED | |
9 | #define BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_ITERATOR_HPP_INCLUDED | |
10 | ||
11 | #include <fstream> | |
12 | #include <iterator> // Back inserter. | |
13 | #include <vector> | |
14 | #include <boost/iostreams/filtering_stream.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 | ||
20 | // Note: adding raw inserter iterators to chains is not supported | |
21 | // on VC6. | |
22 | ||
23 | void write_output_iterator_test() | |
24 | { | |
25 | using namespace std; | |
26 | using namespace boost; | |
27 | using namespace boost::iostreams; | |
28 | using namespace boost::iostreams::test; | |
29 | ||
30 | test_file test; | |
31 | ||
32 | { | |
33 | vector<char> first; | |
34 | filtering_ostream out; | |
35 | out.push(std::back_inserter(first), 0); | |
36 | write_data_in_chars(out); | |
37 | ifstream second(test.name().c_str()); | |
38 | BOOST_CHECK_MESSAGE( | |
39 | compare_container_and_stream(first, second), | |
40 | "failed writing to filtering_ostream based on an " | |
41 | "output iterator in chars with no buffer" | |
42 | ); | |
43 | } | |
44 | ||
45 | { | |
46 | vector<char> first; | |
47 | filtering_ostream out; | |
48 | out.push(std::back_inserter(first), 0); | |
49 | write_data_in_chunks(out); | |
50 | ifstream second(test.name().c_str()); | |
51 | BOOST_CHECK_MESSAGE( | |
52 | compare_container_and_stream(first, second), | |
53 | "failed writing to filtering_ostream based on an " | |
54 | "output iterator in chunks with no buffer" | |
55 | ); | |
56 | } | |
57 | ||
58 | { | |
59 | vector<char> first; | |
60 | filtering_ostream out; | |
61 | out.push(std::back_inserter(first)); | |
62 | write_data_in_chars(out); | |
63 | ifstream second(test.name().c_str()); | |
64 | BOOST_CHECK_MESSAGE( | |
65 | compare_container_and_stream(first, second), | |
66 | "failed writing to filtering_ostream based on an " | |
67 | "output iterator in chars with large buffer" | |
68 | ); | |
69 | } | |
70 | ||
71 | { | |
72 | vector<char> first; | |
73 | filtering_ostream out; | |
74 | out.push(std::back_inserter(first)); | |
75 | write_data_in_chunks(out); | |
76 | ifstream second(test.name().c_str()); | |
77 | BOOST_CHECK_MESSAGE( | |
78 | compare_container_and_stream(first, second), | |
79 | "failed writing to filtering_ostream based on an " | |
80 | "output iterator in chunks with large buffer" | |
81 | ); | |
82 | } | |
83 | } | |
84 | ||
85 | #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_ITERATOR_HPP_INCLUDED |