test: add test for NetworkCoordinate::estimate_rtt
Signed-off-by: Stephen Waits <steve@waits.net>
This commit is contained in:
1 file changed
+12
@@ -304,4 +304,16 @@ mod tests {
|
||||
let t = serde_json::to_string(&a);
|
||||
assert_eq!(t.as_ref().unwrap(), s);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_estimated_rtt() {
|
||||
// start with JSON, deserialize it
|
||||
let s = "{\"position\":[{\"inner\":[1.5,0.5,2.0]},25.0],\"error\":1.0}";
|
||||
let a: NetworkCoordinate<3> = serde_json::from_str(s).unwrap();
|
||||
let s = "{\"position\":[{\"inner\":[-1.5,-0.5,-2.0]},50.0],\"error\":1.0}";
|
||||
let b: NetworkCoordinate<3> = serde_json::from_str(s).unwrap();
|
||||
|
||||
let estimate = a.estimated_rtt(&b);
|
||||
assert_approx_eq!(estimate.as_secs_f32(), 0.080_099);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user