File: bytes.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 (16 lines) | stat: -rw-r--r-- 471 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use asynchronous_codec::{BytesCodec, Framed};
use futures::io::Cursor;
use futures::{executor, TryStreamExt};

#[test]
fn decodes() {
    let mut buf = [0u8; 32];
    let expected = buf;
    let cur = Cursor::new(&mut buf[..]);
    let mut framed = Framed::new(cur, BytesCodec {});

    let read = executor::block_on(framed.try_next()).unwrap().unwrap();
    assert_eq!(&read[..], &expected[..]);

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