1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

test: Add a buffer-backed IO sink (for interactive runs).

This commit is contained in:
Petr Rockai 2014-06-27 00:54:36 +02:00
parent f53fcc0746
commit df27c64041

View File

@ -55,6 +55,23 @@ struct Sink {
virtual void sync() {}
};
struct BufSink : Sink {
std::vector< char > data;
virtual void push( std::string x ) {
std::copy( x.begin(), x.end(), std::back_inserter( data ) );
}
void dump( std::ostream &o ) {
std::vector< char >::iterator b = data.begin(), e = data.begin();
o << std::endl;
while ( e != data.end() ) {
e = std::find( b, data.end(), '\n' );
o << "| " << std::string( b, e ) << std::endl;
b = (e == data.end() ? e : e + 1);
}
}
};
struct FdSink : Sink {
int fd;