mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-29 09:41:34 +00:00
@ -173,10 +173,9 @@ where
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use RwStreamSink;
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::sync::mpsc::channel;
|
use crate::RwStreamSink;
|
||||||
use futures::{Future, Poll, Sink, StartSend, Stream};
|
use futures::{prelude::*, stream, sync::mpsc::channel};
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
// This struct merges a stream and a sink and is quite useful for tests.
|
// This struct merges a stream and a sink and is quite useful for tests.
|
||||||
@ -232,4 +231,13 @@ mod tests {
|
|||||||
wrapper.read_to_end(&mut data2).unwrap();
|
wrapper.read_to_end(&mut data2).unwrap();
|
||||||
assert_eq!(data2, b" world");
|
assert_eq!(data2, b" world");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn skip_empty_stream_items() {
|
||||||
|
let data: Vec<&[u8]> = vec![b"", b"foo", b"", b"bar", b"", b"baz", b""];
|
||||||
|
let mut rws = RwStreamSink::new(stream::iter_ok::<_, std::io::Error>(data));
|
||||||
|
let mut buf = [0; 9];
|
||||||
|
assert_eq!(9, rws.read(&mut buf).unwrap());
|
||||||
|
assert_eq!(b"foobarbaz", &buf[..])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user