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 <boost/iostreams/device/file.hpp> |
---|
8 | #include <boost/test/test_tools.hpp> |
---|
9 | #include <boost/test/unit_test.hpp> |
---|
10 | #include "detail/temp_file.hpp" |
---|
11 | #include "detail/verification.hpp" |
---|
12 | |
---|
13 | using namespace boost; |
---|
14 | using namespace boost::iostreams; |
---|
15 | using namespace boost::iostreams::test; |
---|
16 | using std::ifstream; |
---|
17 | using boost::unit_test::test_suite; |
---|
18 | |
---|
19 | void file_test() |
---|
20 | { |
---|
21 | test_file test; |
---|
22 | |
---|
23 | //--------------Test file_source------------------------------------------// |
---|
24 | |
---|
25 | { |
---|
26 | file_source f(test.name()); |
---|
27 | BOOST_CHECK(f.is_open()); |
---|
28 | f.close(); |
---|
29 | BOOST_CHECK(!f.is_open()); |
---|
30 | f.open(test.name()); |
---|
31 | BOOST_CHECK(f.is_open()); |
---|
32 | } |
---|
33 | |
---|
34 | //--------------Test file_sink--------------------------------------------// |
---|
35 | |
---|
36 | { |
---|
37 | file_sink f(test.name()); |
---|
38 | BOOST_CHECK(f.is_open()); |
---|
39 | f.close(); |
---|
40 | BOOST_CHECK(!f.is_open()); |
---|
41 | f.open(test.name()); |
---|
42 | BOOST_CHECK(f.is_open()); |
---|
43 | } |
---|
44 | |
---|
45 | //--------------Test file-------------------------------------------------// |
---|
46 | |
---|
47 | { |
---|
48 | file f(test.name()); |
---|
49 | BOOST_CHECK(f.is_open()); |
---|
50 | f.close(); |
---|
51 | BOOST_CHECK(!f.is_open()); |
---|
52 | f.open(test.name()); |
---|
53 | BOOST_CHECK(f.is_open()); |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | test_suite* init_unit_test_suite(int, char* []) |
---|
58 | { |
---|
59 | test_suite* test = BOOST_TEST_SUITE("file test"); |
---|
60 | test->add(BOOST_TEST_CASE(&file_test)); |
---|
61 | return test; |
---|
62 | } |
---|