Add unit tests for atan2

This commit is contained in:
Joseph Ryan
2018-07-16 21:18:38 -05:00
parent addfefd63f
commit fe84c2050e

View File

@@ -70,3 +70,14 @@ pub fn atan2(y: f64, x: f64) -> f64 {
_ => (z - PI_LO) - PI, /* atan(-,-) */
}
}
#[test]
fn sanity_check() {
assert_eq!(atan2(0.0, 1.0), 0.0);
assert_eq!(atan2(0.0, -1.0), PI);
assert_eq!(atan2(-0.0, -1.0), -PI);
assert_eq!(atan2(3.0, 2.0), atan(3.0/2.0));
assert_eq!(atan2(2.0, -1.0), atan(2.0/-1.0) + PI);
assert_eq!(atan2(-2.0, -1.0), atan(-2.0/-1.0) - PI);
}