Skip to content

Commit e979c7d

Browse files
bors[bot]P1n3appl3
andcommitted
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#9 Co-authored-by: Joseph Ryan <[email protected]>
2 parents f585251 + d1f3e30 commit e979c7d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/math/atan2.rs

+10
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,13 @@ pub fn atan2(y: f64, x: f64) -> f64 {
7070
_ => (z - PI_LO) - PI, /* atan(-,-) */
7171
}
7272
}
73+
74+
#[test]
75+
fn sanity_check() {
76+
assert_eq!(atan2(0.0, 1.0), 0.0);
77+
assert_eq!(atan2(0.0, -1.0), PI);
78+
assert_eq!(atan2(-0.0, -1.0), -PI);
79+
assert_eq!(atan2(3.0, 2.0), atan(3.0 / 2.0));
80+
assert_eq!(atan2(2.0, -1.0), atan(2.0 / -1.0) + PI);
81+
assert_eq!(atan2(-2.0, -1.0), atan(-2.0 / -1.0) - PI);
82+
}

0 commit comments

Comments
 (0)