Skip to content

Commit

Permalink
simplify isqrt test
Browse files Browse the repository at this point in the history
  • Loading branch information
JSorngard committed Oct 19, 2023
1 parent 60aa83f commit 0e89151
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/imath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ mod test {

#[test]
fn check_isqrt() {
#[rustfmt::skip]
const TEST_CASES: [u64; 100] = [0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9];
for (x, ans) in TEST_CASES.into_iter().enumerate() {
assert_eq!(isqrt(x as u64), ans);
for x in 0..1_000_000 {
assert_eq!(isqrt(x), (x as f64).sqrt().floor() as u64);
}
assert_eq!(
f64::from(u32::MAX).sqrt().floor() as u64,
Expand Down

0 comments on commit 0e89151

Please sign in to comment.