zlib_test.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. // See http://www.boost.org/libs/iostreams for documentation.
  6. #include <string>
  7. #include <boost/iostreams/filter/test.hpp>
  8. #include <boost/iostreams/filter/zlib.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/sequence.hpp"
  13. #include "detail/verification.hpp"
  14. using namespace std;
  15. using namespace boost;
  16. using namespace boost::iostreams;
  17. using namespace boost::iostreams::test;
  18. using boost::unit_test::test_suite;
  19. struct zlib_alloc : std::allocator<char> { };
  20. void zlib_test()
  21. {
  22. text_sequence data;
  23. BOOST_CHECK(
  24. test_filter_pair( zlib_compressor(),
  25. zlib_decompressor(),
  26. std::string(data.begin(), data.end()) )
  27. );
  28. BOOST_CHECK(
  29. test_filter_pair( basic_zlib_compressor<zlib_alloc>(),
  30. basic_zlib_decompressor<zlib_alloc>(),
  31. std::string(data.begin(), data.end()) )
  32. );
  33. BOOST_CHECK(
  34. test_filter_pair( zlib_compressor(),
  35. zlib_decompressor(),
  36. std::string() )
  37. );
  38. {
  39. filtering_istream strm;
  40. strm.push( zlib_compressor() );
  41. strm.push( null_source() );
  42. }
  43. {
  44. filtering_istream strm;
  45. strm.push( zlib_decompressor() );
  46. strm.push( null_source() );
  47. }
  48. }
  49. test_suite* init_unit_test_suite(int, char* [])
  50. {
  51. test_suite* test = BOOST_TEST_SUITE("zlib test");
  52. test->add(BOOST_TEST_CASE(&zlib_test));
  53. return test;
  54. }