We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5eec94c commit a074a57Copy full SHA for a074a57
compio-io/tests/compat.rs
@@ -1,7 +1,7 @@
1
use std::io::Cursor;
2
3
use compio_io::compat::AsyncStream;
4
-use futures_util::{AsyncReadExt, AsyncWriteExt};
+use futures_util::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt};
5
6
#[tokio::test]
7
async fn async_compat_read() {
@@ -20,6 +20,22 @@ async fn async_compat_read() {
20
assert_eq!(&buf[..7], [1, 9, 1, 9, 8, 1, 0]);
21
}
22
23
+#[tokio::test]
24
+async fn async_compat_bufread() {
25
+ let src = &[1u8, 1, 4, 5, 1, 4, 1, 9, 1, 9, 8, 1, 0][..];
26
+ let mut stream = AsyncStream::new(src);
27
+
28
+ let slice = stream.fill_buf().await.unwrap();
29
+ assert_eq!(slice, [1, 1, 4, 5, 1, 4, 1, 9, 1, 9, 8, 1, 0]);
30
+ stream.consume_unpin(6);
31
32
+ let mut buf = [0; 7];
33
+ let len = stream.read(&mut buf).await.unwrap();
34
35
+ assert_eq!(len, 7);
36
+ assert_eq!(buf, [1, 9, 1, 9, 8, 1, 0]);
37
+}
38
39
40
async fn async_compat_write() {
41
let dst = Cursor::new([0u8; 10]);
0 commit comments