From 4d93766a0f6a5e52b7c5d1f4c6287ff33dc5560a Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 23 Oct 2017 14:08:11 -0700 Subject: [PATCH] payload error tests --- src/payload.rs | 13 +++++++++++++ src/wsframe.rs | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/payload.rs b/src/payload.rs index 72f86e773..1e7427d3c 100644 --- a/src/payload.rs +++ b/src/payload.rs @@ -365,9 +365,22 @@ impl Inner { #[cfg(test)] mod tests { use super::*; + use std::io; use futures::future::{lazy, result}; use tokio_core::reactor::Core; + #[test] + fn test_error() { + let err: PayloadError = IoError::new(io::ErrorKind::Other, "ParseError").into(); + assert_eq!(err.description(), "ParseError"); + assert_eq!(err.cause().unwrap().description(), "ParseError"); + assert_eq!(format!("{}", err), "ParseError"); + + let err = PayloadError::Incomplete; + assert_eq!(err.description(), "A payload reached EOF, but is not complete."); + assert_eq!(format!("{}", err), "A payload reached EOF, but is not complete."); + } + #[test] fn test_basic() { Core::new().unwrap().run(lazy(|| { diff --git a/src/wsframe.rs b/src/wsframe.rs index efe0fc47c..3fd09ef4e 100644 --- a/src/wsframe.rs +++ b/src/wsframe.rs @@ -340,7 +340,7 @@ mod tests { assert!(Frame::parse(&mut buf).unwrap().is_none()); buf.extend(b"1"); let frame = Frame::parse(&mut buf).unwrap().unwrap(); - println!("FRAME: {:?}", frame); + println!("FRAME: {}", frame); assert!(!frame.finished); assert_eq!(frame.opcode, OpCode::Text); assert_eq!(frame.payload, &b"1"[..]);