Use matches! macro in tests

pull/168/head
WiredSound 4 years ago
parent 8b88fb2444
commit 79dcf9f77c
  1. 8
      src/protocol/frame/mod.rs
  2. 16
      src/protocol/mod.rs

@ -269,9 +269,9 @@ mod tests {
fn size_limit_hit() {
let raw = Cursor::new(vec![0x82, 0x07, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]);
let mut sock = FrameSocket::new(raw);
match sock.read_frame(Some(5)) {
Err(Error::Capacity(CapacityError::MessageTooLong { size: 7, max_size: 5 })) => {}
_ => panic!(),
}
assert!(matches!(
sock.read_frame(Some(5)),
Err(Error::Capacity(CapacityError::MessageTooLong { size: 7, max_size: 5 }))
));
}
}

@ -713,10 +713,10 @@ mod tests {
let limit = WebSocketConfig { max_message_size: Some(10), ..WebSocketConfig::default() };
let mut socket = WebSocket::from_raw_socket(WriteMoc(incoming), Role::Client, Some(limit));
match socket.read_message() {
Err(Error::Capacity(CapacityError::MessageTooLong { size: 13, max_size: 10 })) => {}
_ => panic!(),
}
assert!(matches!(
socket.read_message(),
Err(Error::Capacity(CapacityError::MessageTooLong { size: 13, max_size: 10 }))
));
}
#[test]
@ -725,9 +725,9 @@ mod tests {
let limit = WebSocketConfig { max_message_size: Some(2), ..WebSocketConfig::default() };
let mut socket = WebSocket::from_raw_socket(WriteMoc(incoming), Role::Client, Some(limit));
match socket.read_message() {
Err(Error::Capacity(CapacityError::MessageTooLong { size: 3, max_size: 2 })) => {}
_ => panic!(),
}
assert!(matches!(
socket.read_message(),
Err(Error::Capacity(CapacityError::MessageTooLong { size: 3, max_size: 2 }))
));
}
}

Loading…
Cancel
Save