Index: bzip2_test.cpp =================================================================== --- bzip2_test.cpp (revision 75519) +++ bzip2_test.cpp (working copy) @@ -87,10 +87,40 @@ BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin() + dest.size() / 2)); } +void data_pad_test() +{ + std::vector temp; + std::string source( "This is test data" ); + std::vector sourceVector( source.begin(), source.end() ); + std::vector dest; + + // Write compressed source to temp + boost::iostreams::filtering_streambuf< boost::iostreams::output > out; + out.push( boost::iostreams::bzip2_compressor() ); + out.push( boost::iostreams::back_inserter( temp ) ); + boost::iostreams::copy( boost::make_iterator_range( source ), out ); + + // Add uncompressed source around the compressed source + temp.insert( temp.begin(), source.begin(), source.end() ); + temp.insert( temp.end(), source.begin(), source.end() ); + + // Read compressed data from temp into dest + boost::iostreams::array_source inStr( &temp[ source.length() ], temp.size() ); + boost::iostreams::filtering_streambuf< boost::iostreams::input > in; + in.push( boost::iostreams::bzip2_decompressor() ); + in.push( inStr ); + boost::iostreams::copy( in, boost::iostreams::back_inserter( dest ) ); + + // Verify the dest and sourceVector are equal + BOOST_REQUIRE_EQUAL(sourceVector.size(), dest.size()); + BOOST_CHECK(std::equal(sourceVector.begin(), sourceVector.end(), dest.begin())); +} + test_suite* init_unit_test_suite(int, char* []) { test_suite* test = BOOST_TEST_SUITE("bzip2 test"); test->add(BOOST_TEST_CASE(&bzip2_test)); test->add(BOOST_TEST_CASE(&multiple_member_test)); + test->add(BOOST_TEST_CASE(&data_pad_test)); return test; }