]>
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 | #include <string> | |
9 | #include <boost/iostreams/filter/test.hpp> | |
10 | #include <boost/iostreams/filter/zlib.hpp> | |
11 | #include <boost/iostreams/filtering_stream.hpp> | |
12 | #include <boost/test/test_tools.hpp> | |
13 | #include <boost/test/unit_test.hpp> | |
14 | #include "detail/sequence.hpp" | |
15 | #include "detail/verification.hpp" | |
16 | ||
17 | using namespace std; | |
18 | using namespace boost; | |
19 | using namespace boost::iostreams; | |
20 | using namespace boost::iostreams::test; | |
21 | using boost::unit_test::test_suite; | |
22 | ||
1e59de90 TL |
23 | template<class T> struct basic_test_alloc: std::allocator<T> |
24 | { | |
25 | basic_test_alloc() | |
26 | { | |
27 | } | |
28 | ||
29 | basic_test_alloc( basic_test_alloc const& /*other*/ ) | |
30 | { | |
31 | } | |
32 | ||
33 | template<class U> | |
34 | basic_test_alloc( basic_test_alloc<U> const & /*other*/ ) | |
35 | { | |
36 | } | |
37 | ||
38 | template<class U> struct rebind | |
39 | { | |
40 | typedef basic_test_alloc<U> other; | |
41 | }; | |
42 | }; | |
43 | ||
44 | typedef basic_test_alloc<char> zlib_alloc; | |
7c673cae FG |
45 | |
46 | void zlib_test() | |
47 | { | |
48 | text_sequence data; | |
49 | BOOST_CHECK( | |
50 | test_filter_pair( zlib_compressor(), | |
51 | zlib_decompressor(), | |
52 | std::string(data.begin(), data.end()) ) | |
53 | ); | |
54 | BOOST_CHECK( | |
55 | test_filter_pair( basic_zlib_compressor<zlib_alloc>(), | |
56 | basic_zlib_decompressor<zlib_alloc>(), | |
57 | std::string(data.begin(), data.end()) ) | |
58 | ); | |
59 | BOOST_CHECK( | |
60 | test_filter_pair( zlib_compressor(), | |
61 | zlib_decompressor(), | |
62 | std::string() ) | |
63 | ); | |
64 | { | |
65 | filtering_istream strm; | |
66 | strm.push( zlib_compressor() ); | |
67 | strm.push( null_source() ); | |
68 | } | |
69 | { | |
70 | filtering_istream strm; | |
71 | strm.push( zlib_decompressor() ); | |
72 | strm.push( null_source() ); | |
73 | } | |
74 | } | |
75 | ||
76 | test_suite* init_unit_test_suite(int, char* []) | |
77 | { | |
78 | test_suite* test = BOOST_TEST_SUITE("zlib test"); | |
79 | test->add(BOOST_TEST_CASE(&zlib_test)); | |
80 | return test; | |
81 | } |