File: lines.rs

package info (click to toggle)
rust-async-codec-lite 0.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 256 kB
  • sloc: makefile: 2
file content (16 lines) | stat: -rw-r--r-- 588 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use async_codec_lite::{Framed, LinesCodec};
use futures_lite::future::block_on;
use futures_util::{io::Cursor, stream::TryStreamExt};

#[test]
fn it_works() {
    let buf = "Hello\nWorld\nError".to_owned();
    let cur = Cursor::new(buf);
    let mut framed = Framed::new(cur, LinesCodec {});
    let next = block_on(framed.try_next()).unwrap();
    assert_eq!(next, Some(String::from("Hello\n")));
    let next = block_on(framed.try_next()).unwrap();
    assert_eq!(next, Some(String::from("World\n")));
    let next = block_on(framed.try_next()).unwrap();
    assert_eq!(next, None);
}