summaryrefslogtreecommitdiffstats
path: root/tokio/tests/io_lines.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tokio/tests/io_lines.rs')
-rw-r--r--tokio/tests/io_lines.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tokio/tests/io_lines.rs b/tokio/tests/io_lines.rs
new file mode 100644
index 00000000..e85fbff7
--- /dev/null
+++ b/tokio/tests/io_lines.rs
@@ -0,0 +1,20 @@
+#![warn(rust_2018_idioms)]
+
+use tokio::io::AsyncBufReadExt;
+use tokio_test::assert_ok;
+
+use futures_util::StreamExt;
+
+#[tokio::test]
+async fn lines() {
+ let rd: &[u8] = b"hello\r\nworld\n\n";
+ let mut st = rd.lines();
+
+ let b = assert_ok!(st.next().await.unwrap());
+ assert_eq!(b, "hello");
+ let b = assert_ok!(st.next().await.unwrap());
+ assert_eq!(b, "world");
+ let b = assert_ok!(st.next().await.unwrap());
+ assert_eq!(b, "");
+ assert!(st.next().await.is_none());
+}