122: Add sanity_check for atan2 r=japaric a=P1n3appl3

It's already been merged, but now I can say with certainty that this closes rust-lang/libm#9 

Co-authored-by: Joseph Ryan <josephryan3.14@gmail.com>
This commit is contained in:
bors[bot] 2018-07-17 03:19:09 +00:00
commit 89c7f41c04

View file

@ -70,3 +70,13 @@ 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);
}