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