refactor: change unwrap()s to expects() and deny in clippy
Signed-off-by: Stephen Waits <steve@waits.net>
This commit is contained in:
1 parent
1e1365ee13
commit
f5ddbc0533
4 files changed
+17
-8
No files matched your search
@@ -368,14 +368,15 @@ mod tests {
|
|||||||
fn test_serde() {
|
fn test_serde() {
|
||||||
// start with JSON, deserialize it
|
// start with JSON, deserialize it
|
||||||
let s = "{\"position\":[1.0,2.0,3.0],\"height\":4.0}";
|
let s = "{\"position\":[1.0,2.0,3.0],\"height\":4.0}";
|
||||||
let a: HeightVector<3> = serde_json::from_str(s).unwrap();
|
let a: HeightVector<3> =
|
||||||
|
serde_json::from_str(s).expect("deserialization failed during test");
|
||||||
|
|
||||||
// make sure it's the right length and works like we expect a normal NC
|
// make sure it's the right length and works like we expect a normal NC
|
||||||
assert_approx_eq!(a.len(), 7.741_657, 0.001);
|
assert_approx_eq!(a.len(), 7.741_657, 0.001);
|
||||||
|
|
||||||
// serialize it into a new JSON string and make sure it matches the original
|
// serialize it into a new JSON string and make sure it matches the original
|
||||||
let t = serde_json::to_string(&a);
|
let t = serde_json::to_string(&a);
|
||||||
assert_eq!(t.as_ref().unwrap(), s);
|
assert_eq!(t.as_ref().expect("serialization failed during test"), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -102,6 +102,7 @@
|
|||||||
#![deny(clippy::cargo)]
|
#![deny(clippy::cargo)]
|
||||||
#![deny(clippy::pedantic)]
|
#![deny(clippy::pedantic)]
|
||||||
#![deny(clippy::nursery)]
|
#![deny(clippy::nursery)]
|
||||||
|
#![deny(clippy::unwrap_used)]
|
||||||
#![allow(clippy::type_repetition_in_bounds)]
|
#![allow(clippy::type_repetition_in_bounds)]
|
||||||
#![allow(clippy::module_name_repetitions)]
|
#![allow(clippy::module_name_repetitions)]
|
||||||
|
|
||||||
|
|||||||
@@ -360,7 +360,8 @@ mod tests {
|
|||||||
fn test_serde() {
|
fn test_serde() {
|
||||||
// start with JSON, deserialize it
|
// start with JSON, deserialize it
|
||||||
let s = "{\"position\":[1.5,0.5,2.0],\"height\":0.1,\"error\":1.0}";
|
let s = "{\"position\":[1.5,0.5,2.0],\"height\":0.1,\"error\":1.0}";
|
||||||
let a: NetworkCoordinate<3> = serde_json::from_str(s).unwrap();
|
let a: NetworkCoordinate<3> =
|
||||||
|
serde_json::from_str(s).expect("deserialization failed during test");
|
||||||
|
|
||||||
// make sure it's the right length and works like we expect a normal NC
|
// make sure it's the right length and works like we expect a normal NC
|
||||||
assert_approx_eq!(a.heightvec.len(), 2.649_509, 0.001);
|
assert_approx_eq!(a.heightvec.len(), 2.649_509, 0.001);
|
||||||
@@ -369,16 +370,18 @@ mod tests {
|
|||||||
|
|
||||||
// serialize it into a new JSON string and make sure it matches the original
|
// serialize it into a new JSON string and make sure it matches the original
|
||||||
let t = serde_json::to_string(&a);
|
let t = serde_json::to_string(&a);
|
||||||
assert_eq!(t.as_ref().unwrap(), s);
|
assert_eq!(t.as_ref().expect("serialization failed during test"), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_estimated_rtt() {
|
fn test_estimated_rtt() {
|
||||||
// start with JSON, deserialize it
|
// start with JSON, deserialize it
|
||||||
let s = "{\"position\":[1.5,0.5,2.0],\"height\":25.0,\"error\":1.0}";
|
let s = "{\"position\":[1.5,0.5,2.0],\"height\":25.0,\"error\":1.0}";
|
||||||
let a: NetworkCoordinate<3> = serde_json::from_str(s).unwrap();
|
let a: NetworkCoordinate<3> =
|
||||||
|
serde_json::from_str(s).expect("deserialization failed during test");
|
||||||
let s = "{\"position\":[-1.5,-0.5,-2.0],\"height\":50.0,\"error\":1.0}";
|
let s = "{\"position\":[-1.5,-0.5,-2.0],\"height\":50.0,\"error\":1.0}";
|
||||||
let b: NetworkCoordinate<3> = serde_json::from_str(s).unwrap();
|
let b: NetworkCoordinate<3> =
|
||||||
|
serde_json::from_str(s).expect("deserialization failed during test");
|
||||||
|
|
||||||
let estimate = a.estimated_rtt(&b);
|
let estimate = a.estimated_rtt(&b);
|
||||||
assert_approx_eq!(estimate.as_secs_f32(), 0.080_099);
|
assert_approx_eq!(estimate.as_secs_f32(), 0.080_099);
|
||||||
@@ -387,7 +390,8 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_error_getter() {
|
fn test_error_getter() {
|
||||||
let s = "{\"position\":[1.5,0.5,2.0],\"height\":25.0,\"error\":1.0}";
|
let s = "{\"position\":[1.5,0.5,2.0],\"height\":25.0,\"error\":1.0}";
|
||||||
let a: NetworkCoordinate<3> = serde_json::from_str(s).unwrap();
|
let a: NetworkCoordinate<3> =
|
||||||
|
serde_json::from_str(s).expect("deserialization failed during test");
|
||||||
assert_approx_eq!(a.error(), 1.0);
|
assert_approx_eq!(a.error(), 1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-1
@@ -285,7 +285,10 @@ mod tests {
|
|||||||
fn test_serde() {
|
fn test_serde() {
|
||||||
let a = Vector::<f32, 3>::from([1.0, 2.0, 3.0]);
|
let a = Vector::<f32, 3>::from([1.0, 2.0, 3.0]);
|
||||||
let s = serde_json::to_string(&a);
|
let s = serde_json::to_string(&a);
|
||||||
assert_eq!(s.as_ref().unwrap(), "{\"position\":[1.0,2.0,3.0]}");
|
assert_eq!(
|
||||||
|
s.as_ref().expect("serialization failed in test"),
|
||||||
|
"{\"position\":[1.0,2.0,3.0]}"
|
||||||
|
);
|
||||||
assert!(s.is_ok());
|
assert!(s.is_ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user