Files
tokio/tokio/tests/io_lines.rs
T
Carl Lerche 987ba7373c io: move into tokio crate (#1691)
A step towards collapsing Tokio sub crates into a single `tokio`
crate (#1318).

The `io` implementation is now provided by the main `tokio` crate.
Functionality can be opted out of by using the various net related
feature flags.
2019-10-26 08:02:49 -07:00

21 lines
496 B
Rust

#![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());
}