mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
more Body tests
This commit is contained in:
parent
83862dfbb4
commit
766e243c63
22
src/body.rs
22
src/body.rs
@ -205,6 +205,12 @@ impl From<Binary> for Frame {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_is_empty() {
|
||||||
|
assert_eq!(Binary::from("").is_empty(), true);
|
||||||
|
assert_eq!(Binary::from("test").is_empty(), false);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_static_str() {
|
fn test_static_str() {
|
||||||
assert_eq!(Binary::from("test").len(), 4);
|
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).len(), 4);
|
||||||
assert_eq!(Binary::from(&b).as_ref(), "test".as_bytes());
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user