mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 08:22:59 +01:00
clippy warns
This commit is contained in:
parent
eeae0ddab4
commit
7be4b1f399
26
src/body.rs
26
src/body.rs
@ -281,61 +281,61 @@ mod tests {
|
||||
#[test]
|
||||
fn test_static_str() {
|
||||
assert_eq!(Binary::from("test").len(), 4);
|
||||
assert_eq!(Binary::from("test").as_ref(), "test".as_bytes());
|
||||
assert_eq!(Binary::from("test").as_ref(), b"test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_static_bytes() {
|
||||
assert_eq!(Binary::from(b"test".as_ref()).len(), 4);
|
||||
assert_eq!(Binary::from(b"test".as_ref()).as_ref(), "test".as_bytes());
|
||||
assert_eq!(Binary::from(b"test".as_ref()).as_ref(), b"test");
|
||||
assert_eq!(Binary::from_slice(b"test".as_ref()).len(), 4);
|
||||
assert_eq!(Binary::from_slice(b"test".as_ref()).as_ref(), "test".as_bytes());
|
||||
assert_eq!(Binary::from_slice(b"test".as_ref()).as_ref(), b"test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_vec() {
|
||||
assert_eq!(Binary::from(Vec::from("test")).len(), 4);
|
||||
assert_eq!(Binary::from(Vec::from("test")).as_ref(), "test".as_bytes());
|
||||
assert_eq!(Binary::from(Vec::from("test")).as_ref(), b"test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bytes() {
|
||||
assert_eq!(Binary::from(Bytes::from("test")).len(), 4);
|
||||
assert_eq!(Binary::from(Bytes::from("test")).as_ref(), "test".as_bytes());
|
||||
assert_eq!(Binary::from(Bytes::from("test")).as_ref(), b"test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ref_string() {
|
||||
let b = Rc::new("test".to_owned());
|
||||
assert_eq!(Binary::from(&b).len(), 4);
|
||||
assert_eq!(Binary::from(&b).as_ref(), "test".as_bytes());
|
||||
assert_eq!(Binary::from(&b).as_ref(), b"test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rc_string() {
|
||||
let b = Rc::new("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.clone()).as_ref(), b"test");
|
||||
assert_eq!(Binary::from(&b).len(), 4);
|
||||
assert_eq!(Binary::from(&b).as_ref(), "test".as_bytes());
|
||||
assert_eq!(Binary::from(&b).as_ref(), b"test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_arc_string() {
|
||||
let b = Arc::new("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.clone()).as_ref(), b"test");
|
||||
assert_eq!(Binary::from(&b).len(), 4);
|
||||
assert_eq!(Binary::from(&b).as_ref(), "test".as_bytes());
|
||||
assert_eq!(Binary::from(&b).as_ref(), b"test");
|
||||
}
|
||||
|
||||
#[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.clone()).as_ref(), b"test");
|
||||
assert_eq!(Binary::from(&b).len(), 4);
|
||||
assert_eq!(Binary::from(&b).as_ref(), "test".as_bytes());
|
||||
assert_eq!(Binary::from(&b).as_ref(), b"test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -351,7 +351,7 @@ mod tests {
|
||||
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());
|
||||
assert_eq!(Binary::from(b).as_ref(), b"test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -319,7 +319,7 @@ mod tests {
|
||||
}
|
||||
let entry_time = time::now();
|
||||
let render = |fmt: &mut Formatter| {
|
||||
for unit in logger.format.0.iter() {
|
||||
for unit in &logger.format.0 {
|
||||
unit.render(fmt, &req, &resp, entry_time)?;
|
||||
}
|
||||
Ok(())
|
||||
@ -340,7 +340,7 @@ mod tests {
|
||||
let entry_time = time::now();
|
||||
|
||||
let render = |fmt: &mut Formatter| {
|
||||
for unit in format.0.iter() {
|
||||
for unit in &format.0 {
|
||||
unit.render(fmt, &req, &resp, entry_time)?;
|
||||
}
|
||||
Ok(())
|
||||
@ -357,7 +357,7 @@ mod tests {
|
||||
let entry_time = time::now();
|
||||
|
||||
let render = |fmt: &mut Formatter| {
|
||||
for unit in format.0.iter() {
|
||||
for unit in &format.0 {
|
||||
unit.render(fmt, &req, &resp, entry_time)?;
|
||||
}
|
||||
Ok(())
|
||||
|
@ -1425,7 +1425,7 @@ mod tests {
|
||||
|
||||
let mut reader = Reader::new();
|
||||
let mut req = reader_parse_ready!(reader.parse(&mut buf, &mut readbuf, &settings));
|
||||
let _ = req.payload_mut().set_read_buffer_capacity(0);
|
||||
req.payload_mut().set_read_buffer_capacity(0);
|
||||
assert!(req.chunked().unwrap());
|
||||
assert!(!req.payload().eof());
|
||||
|
||||
|
@ -354,8 +354,8 @@ mod tests {
|
||||
use super::*;
|
||||
use futures::stream::once;
|
||||
|
||||
fn is_none(frm: Poll<Option<Frame>, ProtocolError>) -> bool {
|
||||
match frm {
|
||||
fn is_none(frm: &Poll<Option<Frame>, ProtocolError>) -> bool {
|
||||
match *frm {
|
||||
Ok(Async::Ready(None)) => true,
|
||||
_ => false,
|
||||
}
|
||||
@ -371,10 +371,10 @@ mod tests {
|
||||
#[test]
|
||||
fn test_parse() {
|
||||
let mut buf = PayloadHelper::new(
|
||||
once(Ok(BytesMut::from(&[0b00000001u8, 0b00000001u8][..]).freeze())));
|
||||
assert!(is_none(Frame::parse(&mut buf, false, 1024)));
|
||||
once(Ok(BytesMut::from(&[0b0000_0001u8, 0b0000_0001u8][..]).freeze())));
|
||||
assert!(is_none(&Frame::parse(&mut buf, false, 1024)));
|
||||
|
||||
let mut buf = BytesMut::from(&[0b00000001u8, 0b00000001u8][..]);
|
||||
let mut buf = BytesMut::from(&[0b0000_0001u8, 0b0000_0001u8][..]);
|
||||
buf.extend(b"1");
|
||||
let mut buf = PayloadHelper::new(once(Ok(buf.freeze())));
|
||||
|
||||
@ -386,7 +386,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_parse_length0() {
|
||||
let buf = BytesMut::from(&[0b00000001u8, 0b00000000u8][..]);
|
||||
let buf = BytesMut::from(&[0b0000_0001u8, 0b0000_0000u8][..]);
|
||||
let mut buf = PayloadHelper::new(once(Ok(buf.freeze())));
|
||||
|
||||
let frame = extract(Frame::parse(&mut buf, false, 1024));
|
||||
@ -397,11 +397,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_parse_length2() {
|
||||
let buf = BytesMut::from(&[0b00000001u8, 126u8][..]);
|
||||
let buf = BytesMut::from(&[0b0000_0001u8, 126u8][..]);
|
||||
let mut buf = PayloadHelper::new(once(Ok(buf.freeze())));
|
||||
assert!(is_none(Frame::parse(&mut buf, false, 1024)));
|
||||
assert!(is_none(&Frame::parse(&mut buf, false, 1024)));
|
||||
|
||||
let mut buf = BytesMut::from(&[0b00000001u8, 126u8][..]);
|
||||
let mut buf = BytesMut::from(&[0b0000_0001u8, 126u8][..]);
|
||||
buf.extend(&[0u8, 4u8][..]);
|
||||
buf.extend(b"1234");
|
||||
let mut buf = PayloadHelper::new(once(Ok(buf.freeze())));
|
||||
@ -414,11 +414,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_parse_length4() {
|
||||
let buf = BytesMut::from(&[0b00000001u8, 127u8][..]);
|
||||
let buf = BytesMut::from(&[0b0000_0001u8, 127u8][..]);
|
||||
let mut buf = PayloadHelper::new(once(Ok(buf.freeze())));
|
||||
assert!(is_none(Frame::parse(&mut buf, false, 1024)));
|
||||
assert!(is_none(&Frame::parse(&mut buf, false, 1024)));
|
||||
|
||||
let mut buf = BytesMut::from(&[0b00000001u8, 127u8][..]);
|
||||
let mut buf = BytesMut::from(&[0b0000_0001u8, 127u8][..]);
|
||||
buf.extend(&[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 4u8][..]);
|
||||
buf.extend(b"1234");
|
||||
let mut buf = PayloadHelper::new(once(Ok(buf.freeze())));
|
||||
@ -431,7 +431,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_parse_frame_mask() {
|
||||
let mut buf = BytesMut::from(&[0b00000001u8, 0b10000001u8][..]);
|
||||
let mut buf = BytesMut::from(&[0b0000_0001u8, 0b1000_0001u8][..]);
|
||||
buf.extend(b"0001");
|
||||
buf.extend(b"1");
|
||||
let mut buf = PayloadHelper::new(once(Ok(buf.freeze())));
|
||||
@ -446,7 +446,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_parse_frame_no_mask() {
|
||||
let mut buf = BytesMut::from(&[0b00000001u8, 0b00000001u8][..]);
|
||||
let mut buf = BytesMut::from(&[0b0000_0001u8, 0b0000_0001u8][..]);
|
||||
buf.extend(&[1u8]);
|
||||
let mut buf = PayloadHelper::new(once(Ok(buf.freeze())));
|
||||
|
||||
@ -460,7 +460,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_parse_frame_max_size() {
|
||||
let mut buf = BytesMut::from(&[0b00000001u8, 0b00000010u8][..]);
|
||||
let mut buf = BytesMut::from(&[0b0000_0001u8, 0b0000_0010u8][..]);
|
||||
buf.extend(&[1u8, 1u8]);
|
||||
let mut buf = PayloadHelper::new(once(Ok(buf.freeze())));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user