File: lines.rs

package info (click to toggle)
rust-asynchronous-codec 0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208 kB
  • sloc: makefile: 2
file content (17 lines) | stat: -rw-r--r-- 552 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use asynchronous_codec::{FramedRead, LinesCodec};
use futures::io::Cursor;
use futures::{executor, TryStreamExt};

#[test]
fn it_works() {
    let buf = "Hello\nWorld\nError".to_owned();
    let cur = Cursor::new(buf);

    let mut framed = FramedRead::new(cur, LinesCodec {});
    let next = executor::block_on(framed.try_next()).unwrap().unwrap();
    assert_eq!(next, "Hello\n");
    let next = executor::block_on(framed.try_next()).unwrap().unwrap();
    assert_eq!(next, "World\n");

    assert!(executor::block_on(framed.try_next()).is_err());
}