mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-06 00:00:10 +02:00
impl AsyncWrite for std::io::Cursor (#1730)
Based on the implementation from the futures crate.
This commit is contained in:
committed by
Taiki Endo
parent
e19bd77ef0
commit
6b35a1e8b0
@@ -44,3 +44,14 @@ async fn write() {
|
||||
assert_eq!(n, 4);
|
||||
assert_eq!(wr.buf, b"hell"[..]);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn write_cursor() {
|
||||
use std::io::Cursor;
|
||||
|
||||
let mut wr = Cursor::new(Vec::new());
|
||||
|
||||
let n = assert_ok!(wr.write(b"hello world").await);
|
||||
assert_eq!(n, 11);
|
||||
assert_eq!(wr.get_ref().as_slice(), &b"hello world"[..]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user