1 | // (C) Copyright Jonathan Turkanis 2004 |
---|
2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
---|
3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) |
---|
4 | |
---|
5 | // See http://www.boost.org/libs/iostreams for documentation. |
---|
6 | |
---|
7 | #include <fstream> |
---|
8 | #include <boost/iostreams/device/file.hpp> |
---|
9 | #include <boost/iostreams/filtering_stream.hpp> |
---|
10 | #include <boost/test/test_tools.hpp> |
---|
11 | #include <boost/test/unit_test.hpp> |
---|
12 | #include "detail/temp_file.hpp" |
---|
13 | #include "detail/verification.hpp" |
---|
14 | |
---|
15 | using namespace std; |
---|
16 | using namespace boost; |
---|
17 | using namespace boost::iostreams; |
---|
18 | using namespace boost::iostreams::test; |
---|
19 | using boost::unit_test::test_suite; |
---|
20 | |
---|
21 | void seekable_file_test() |
---|
22 | { |
---|
23 | { |
---|
24 | temp_file temp; |
---|
25 | file f( temp.name(), |
---|
26 | BOOST_IOS::in | BOOST_IOS::out | |
---|
27 | BOOST_IOS::trunc | BOOST_IOS::binary); |
---|
28 | filtering_stream<seekable> io(f); |
---|
29 | io.exceptions(BOOST_IOS::failbit | BOOST_IOS::badbit); |
---|
30 | BOOST_CHECK_MESSAGE( |
---|
31 | test_seekable_in_chars(io), |
---|
32 | "failed seeking within a file, in chars" |
---|
33 | ); |
---|
34 | } |
---|
35 | |
---|
36 | { |
---|
37 | temp_file temp; |
---|
38 | file f( temp.name(), |
---|
39 | BOOST_IOS::in | BOOST_IOS::out | |
---|
40 | BOOST_IOS::trunc | BOOST_IOS::binary); |
---|
41 | filtering_stream<seekable> io(f); |
---|
42 | io.exceptions(BOOST_IOS::failbit | BOOST_IOS::badbit); |
---|
43 | BOOST_CHECK_MESSAGE( |
---|
44 | test_seekable_in_chunks(io), |
---|
45 | "failed seeking within a file, in chunks" |
---|
46 | ); |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | test_suite* init_unit_test_suite(int, char* []) |
---|
51 | { |
---|
52 | test_suite* test = BOOST_TEST_SUITE("seekable file test"); |
---|
53 | test->add(BOOST_TEST_CASE(&seekable_file_test)); |
---|
54 | return test; |
---|
55 | } |
---|