From 79dcf9f77c04133608d1e07ba1d555d93d11de4a Mon Sep 17 00:00:00 2001 From: WiredSound Date: Mon, 11 Jan 2021 12:21:40 +0000 Subject: [PATCH] Use matches! macro in tests --- src/protocol/frame/mod.rs | 8 ++++---- src/protocol/mod.rs | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/protocol/frame/mod.rs b/src/protocol/frame/mod.rs index ba190e5..1e41853 100644 --- a/src/protocol/frame/mod.rs +++ b/src/protocol/frame/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 })) + )); } } diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index b7dc177..215b061 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -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 })) + )); } }