Merge pull request #341 from n1net4il/pr-341932a7

Improve test code for pythagorean (assignment10)
This commit is contained in:
Woojin Lee
2023-12-16 13:35:27 +09:00
committed by GitHub

View File

@@ -340,12 +340,17 @@ mod test {
(68, 285, 293), (68, 285, 293),
]; ];
for (i, t) in pythagorean().enumerate().take(1000) { let mut pythagorean_iter = pythagorean();
if i < pythagoreans.len() { for i in 0..1000 {
assert_eq!(pythagoreans[i], t) let t = pythagorean_iter.next();
} assert!(t.is_some());
let (a, b, c) = t;
let (a, b, c) = t.unwrap();
assert_eq!(a * a + b * b, c * c); assert_eq!(a * a + b * b, c * c);
if i < pythagoreans.len() {
assert_eq!(pythagoreans[i], (a, b, c))
}
} }
} }
} }