Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/iostreams/test/copy_test.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.3 KB
Line 
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/config.hpp>  // MSVC.
9#include <boost/detail/workaround.hpp>
10#include <boost/iostreams/copy.hpp>
11#include <boost/iostreams/device/file.hpp>
12#include <boost/test/test_tools.hpp>
13#include <boost/test/unit_test.hpp>
14#include "detail/temp_file.hpp"
15#include "detail/verification.hpp"
16
17using namespace std;
18using namespace boost;
19using namespace boost::iostreams;
20using namespace boost::iostreams::test;
21using boost::unit_test::test_suite;
22
23void copy_test()
24{
25    test_file test;         
26
27    {
28        temp_file  dest;
29        ifstream   first(test.name().c_str(), in_mode);
30        ofstream   second(dest.name().c_str(), out_mode);
31        boost::iostreams::copy(first, second);
32        first.close();
33        second.close();
34        BOOST_CHECK_MESSAGE(
35            compare_files(test.name(), dest.name()),
36            "failed copying from stream to stream"
37        );
38    }
39
40    {
41        temp_file  dest;
42        ifstream   first(test.name().c_str(), in_mode);
43        boost::iostreams::copy(first, file_sink(dest.name(), out_mode));
44        first.close();
45        BOOST_CHECK_MESSAGE(
46            compare_files(test.name(), dest.name()),
47            "failed copying from stream to file_sink"
48        );
49    }
50
51    {
52        temp_file  dest;
53        ofstream   second(dest.name().c_str(), out_mode);
54        boost::iostreams::copy(file_source(test.name(), in_mode), second);
55        second.close();
56        BOOST_CHECK_MESSAGE(
57            compare_files(test.name(), dest.name()),
58            "failed copying from file_source to stream"
59        );
60    }
61
62    {
63        temp_file dest;
64        boost::iostreams::copy( file_source(test.name(), in_mode),
65                                file_sink(dest.name(), out_mode) );
66        BOOST_CHECK_MESSAGE(
67            compare_files(test.name(), dest.name()),
68            "failed copying from file_source to file_sink"
69        );
70    }
71}
72
73test_suite* init_unit_test_suite(int, char* []) 
74{
75    test_suite* test = BOOST_TEST_SUITE("copy test");
76    test->add(BOOST_TEST_CASE(&copy_test));
77    return test;
78}
Note: See TracBrowser for help on using the repository browser.