From 63ec3a43aab8a9e65ebcf9f202823e3750c3f3c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Sat, 4 Jun 2022 19:25:11 +0200 Subject: [PATCH] common: Split test assertions --- crates/ruma-common/src/time.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/crates/ruma-common/src/time.rs b/crates/ruma-common/src/time.rs index cd12e727..bb818bc4 100644 --- a/crates/ruma-common/src/time.rs +++ b/crates/ruma-common/src/time.rs @@ -89,7 +89,6 @@ fn f64_to_uint(val: f64) -> UInt { mod tests { use std::time::{Duration, UNIX_EPOCH}; - use assert_matches::assert_matches; use js_int::uint; use serde::{Deserialize, Serialize}; use serde_json::json; @@ -106,12 +105,9 @@ mod tests { fn deserialize() { let json = json!({ "millis": 3000, "secs": 60 }); - assert_matches!( - serde_json::from_value::(json), - Ok(SystemTimeTest { millis, secs }) - if millis.to_system_time() == Some(UNIX_EPOCH + Duration::from_millis(3000)) - && secs.to_system_time() == Some(UNIX_EPOCH + Duration::from_secs(60)) - ); + let time = serde_json::from_value::(json).unwrap(); + assert_eq!(time.millis.to_system_time(), Some(UNIX_EPOCH + Duration::from_millis(3000))); + assert_eq!(time.secs.to_system_time(), Some(UNIX_EPOCH + Duration::from_secs(60))); } #[test] @@ -121,9 +117,7 @@ mod tests { .unwrap(), secs: SecondsSinceUnixEpoch(uint!(0)), }; - assert_matches!( - serde_json::to_value(&request), - Ok(value) if value == json!({ "millis": 2000, "secs": 0 }) - ); + + assert_eq!(serde_json::to_value(&request).unwrap(), json!({ "millis": 2000, "secs": 0 })); } }