From 766e243c63d343028cbfdec8005fc57a05ffa9aa Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 19 Nov 2017 18:32:37 -1000 Subject: [PATCH] more Body tests --- src/body.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/body.rs b/src/body.rs index 405d6dfc..7c1eaab3 100644 --- a/src/body.rs +++ b/src/body.rs @@ -205,6 +205,12 @@ impl From for Frame { mod tests { use super::*; + #[test] + fn test_is_empty() { + assert_eq!(Binary::from("").is_empty(), true); + assert_eq!(Binary::from("test").is_empty(), false); + } + #[test] fn test_static_str() { assert_eq!(Binary::from("test").len(), 4); @@ -273,4 +279,20 @@ mod tests { assert_eq!(Binary::from(&b).len(), 4); assert_eq!(Binary::from(&b).as_ref(), "test".as_bytes()); } + + #[test] + fn test_string() { + let b = "test".to_owned(); + assert_eq!(Binary::from(b.clone()).len(), 4); + assert_eq!(Binary::from(b.clone()).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from(&b).len(), 4); + assert_eq!(Binary::from(&b).as_ref(), "test".as_bytes()); + } + + #[test] + fn test_bytes_mut() { + let b = BytesMut::from("test"); + assert_eq!(Binary::from(b.clone()).len(), 4); + assert_eq!(Binary::from(b).as_ref(), "test".as_bytes()); + } }