From 0e89151b71567353b0cc0e3b03bd83d4a4ea3e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Thu, 19 Oct 2023 19:29:19 +0200 Subject: [PATCH] simplify isqrt test --- src/imath.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/imath.rs b/src/imath.rs index c576025..b600d2a 100644 --- a/src/imath.rs +++ b/src/imath.rs @@ -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,