你说的对。
似乎变更集#63057 只解决了部分问题。
不过,相应的单元测试确实有效。但它使用copy
算法(也使用 acomposite<>
而不是 a filtering_istream
,如果相关的话)。
我会将此作为缺陷或回归打开。当然,包括一个显示问题的文件。/etc/dictionaries-common/words
对我来说,它是使用压缩的pbzip2
(默认选项)复制的。
我在test.bz2
这里:http: //7f0d2fd2-af79-415c-ab60-033d3b494dc9.s3.amazonaws.com/test.bz2
这是我的测试程序:
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/stream.hpp>
#include <fstream>
#include <iostream>
namespace io = boost::iostreams;
void multiple_member_test(); // from the unit tests in changeset #63057
int main() {
//multiple_member_test();
//return 0;
std::ifstream trans_file("test.bz2", std::ios::binary);
//Set up boost bzip2 compression
io::filtering_istream in;
in.push(io::bzip2_decompressor());
in.push(trans_file);
//Begin reading
std::string str;
while(std::getline(in, str))
{
std::cout << str << "\n";
}
}
#include <boost/iostreams/compose.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/device/back_inserter.hpp>
#include <cassert>
#include <sstream>
void multiple_member_test() // from the unit tests in changeset #63057
{
std::string data(20ul << 20, '*');
std::vector<char> temp, dest;
// Write compressed data to temp, twice in succession
io::filtering_ostream out;
out.push(io::bzip2_compressor());
out.push(io::back_inserter(temp));
io::copy(boost::make_iterator_range(data), out);
out.push(io::back_inserter(temp));
io::copy(boost::make_iterator_range(data), out);
// Read compressed data from temp into dest
io::filtering_istream in;
in.push(io::bzip2_decompressor());
in.push(io::array_source(&temp[0], temp.size()));
io::copy(in, io::back_inserter(dest));
// Check that dest consists of two copies of data
assert(data.size() * 2 == dest.size());
assert(std::equal(data.begin(), data.end(), dest.begin()));
assert(std::equal(data.begin(), data.end(), dest.begin() + dest.size() / 2));
dest.clear();
io::copy(
io::array_source(&temp[0], temp.size()),
io::compose(io::bzip2_decompressor(), io::back_inserter(dest)));
// Check that dest consists of two copies of data
assert(data.size() * 2 == dest.size());
assert(std::equal(data.begin(), data.end(), dest.begin()));
assert(std::equal(data.begin(), data.end(), dest.begin() + dest.size() / 2));
}