From 5f90d0bcd653ec10f495231f14e849774c713816 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 22 Oct 2017 20:19:20 -0700 Subject: [PATCH] unread_data tests --- src/payload.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/payload.rs b/src/payload.rs index 6f24d5c9e..e92187345 100644 --- a/src/payload.rs +++ b/src/payload.rs @@ -563,4 +563,23 @@ mod test { result(res) })).unwrap(); } + + #[test] + fn test_unread_data() { + Core::new().unwrap().run(lazy(|| { + let (_, mut payload) = Payload::new(false); + + payload.unread_data(Bytes::from("data")); + assert!(!payload.is_empty()); + assert_eq!(payload.len(), 4); + + match payload.readany() { + Async::Ready(Some(data)) => assert_eq!(&data.unwrap(), "data"), + _ => panic!("error"), + } + + let res: Result<(), ()> = Ok(()); + result(res) + })).unwrap(); + } }