mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-19 14:04:17 +03:00
test: Add a buffer-backed IO sink (for interactive runs).
This commit is contained in:
parent
f53fcc0746
commit
df27c64041
@ -55,6 +55,23 @@ struct Sink {
|
|||||||
virtual void sync() {}
|
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 {
|
struct FdSink : Sink {
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user