summaryrefslogtreecommitdiffstats
path: root/tokio/tests/io_read_to_string.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tokio/tests/io_read_to_string.rs')
-rw-r--r--tokio/tests/io_read_to_string.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tokio/tests/io_read_to_string.rs b/tokio/tests/io_read_to_string.rs
new file mode 100644
index 00000000..270d1e48
--- /dev/null
+++ b/tokio/tests/io_read_to_string.rs
@@ -0,0 +1,14 @@
+#![warn(rust_2018_idioms)]
+
+use tokio::io::AsyncReadExt;
+use tokio_test::assert_ok;
+
+#[tokio::test]
+async fn read_to_string() {
+ let mut buf = String::new();
+ let mut rd: &[u8] = b"hello world";
+
+ let n = assert_ok!(rd.read_to_string(&mut buf).await);
+ assert_eq!(n, 11);
+ assert_eq!(buf[..], "hello world"[..]);
+}