Ticket #5291: bzip2_test_patch

File bzip2_test_patch, 1.7 KB (added by chris.steenwyk@…, 11 years ago)

Patch file for libs/iostreams/test/bzip2_test.cpp

Line 
1Index: bzip2_test.cpp
2===================================================================
3--- bzip2_test.cpp (revision 75519)
4+++ bzip2_test.cpp (working copy)
5@@ -87,10 +87,40 @@
6 BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin() + dest.size() / 2));
7 }
8
9+void data_pad_test()
10+{
11+ std::vector<char> temp;
12+ std::string source( "This is test data" );
13+ std::vector<char> sourceVector( source.begin(), source.end() );
14+ std::vector<char> dest;
15+
16+ // Write compressed source to temp
17+ boost::iostreams::filtering_streambuf< boost::iostreams::output > out;
18+ out.push( boost::iostreams::bzip2_compressor() );
19+ out.push( boost::iostreams::back_inserter( temp ) );
20+ boost::iostreams::copy( boost::make_iterator_range( source ), out );
21+
22+ // Add uncompressed source around the compressed source
23+ temp.insert( temp.begin(), source.begin(), source.end() );
24+ temp.insert( temp.end(), source.begin(), source.end() );
25+
26+ // Read compressed data from temp into dest
27+ boost::iostreams::array_source inStr( &temp[ source.length() ], temp.size() );
28+ boost::iostreams::filtering_streambuf< boost::iostreams::input > in;
29+ in.push( boost::iostreams::bzip2_decompressor() );
30+ in.push( inStr );
31+ boost::iostreams::copy( in, boost::iostreams::back_inserter( dest ) );
32+
33+ // Verify the dest and sourceVector are equal
34+ BOOST_REQUIRE_EQUAL(sourceVector.size(), dest.size());
35+ BOOST_CHECK(std::equal(sourceVector.begin(), sourceVector.end(), dest.begin()));
36+}
37+
38 test_suite* init_unit_test_suite(int, char* [])
39 {
40 test_suite* test = BOOST_TEST_SUITE("bzip2 test");
41 test->add(BOOST_TEST_CASE(&bzip2_test));
42 test->add(BOOST_TEST_CASE(&multiple_member_test));
43+ test->add(BOOST_TEST_CASE(&data_pad_test));
44 return test;
45 }