Ticket #3723: gzip.patch

File gzip.patch, 2.0 KB (added by Daniel James, 13 years ago)
  • boost/iostreams/filter/gzip.hpp

     
    3232#include <boost/iostreams/detail/adapter/range_adapter.hpp>
    3333#include <boost/iostreams/detail/char_traits.hpp>
    3434#include <boost/iostreams/detail/ios.hpp> // failure.
     35#include <boost/iostreams/detail/error.hpp>
    3536#include <boost/iostreams/operations.hpp>
    3637#include <boost/iostreams/device/back_inserter.hpp>
    3738#include <boost/iostreams/filter/zlib.hpp>
     
    531532        {
    532533            if (offset_) {
    533534                putback_[--offset_] = c;
    534                 return true;
    535535            } else {
    536                 return boost::iostreams::putback(src_, c);
     536                boost::throw_exception(
     537                    boost::iostreams::detail::bad_putback());
    537538            }
     539            return true;
    538540        }
    539541        void putback(const string_type& s)
    540542        {
  • libs/iostreams/test/gzip_test.cpp

     
    8383    BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin() + dest.size() / 2));
    8484}
    8585
     86void array_source_test()
     87{
     88    std::string data = "simple test string.";
     89    std::string encoded;
     90
     91    filtering_ostream out;
     92    out.push(gzip_compressor());
     93    out.push(io::back_inserter(encoded));
     94    io::copy(make_iterator_range(data), out);
     95
     96    std::string res;
     97    io::array_source src(encoded.data(),encoded.length());
     98    io::copy(io::compose(io::gzip_decompressor(), src), io::back_inserter(res));
     99   
     100    BOOST_CHECK_EQUAL(data, res);
     101}
     102
    86103test_suite* init_unit_test_suite(int, char* [])
    87104{
    88105    test_suite* test = BOOST_TEST_SUITE("gzip test");
    89106    test->add(BOOST_TEST_CASE(&compression_test));
    90107    test->add(BOOST_TEST_CASE(&multiple_member_test));
     108    test->add(BOOST_TEST_CASE(&array_source_test));
    91109    return test;
    92110}