mirror of
https://github.com/kmc7468/cs220.git
synced 2025-12-12 21:08:45 +00:00
Merge pull request #341 from n1net4il/pr-341932a7
Improve test code for pythagorean (assignment10)
This commit is contained in:
@@ -340,12 +340,17 @@ mod test {
|
||||
(68, 285, 293),
|
||||
];
|
||||
|
||||
for (i, t) in pythagorean().enumerate().take(1000) {
|
||||
if i < pythagoreans.len() {
|
||||
assert_eq!(pythagoreans[i], t)
|
||||
}
|
||||
let (a, b, c) = t;
|
||||
let mut pythagorean_iter = pythagorean();
|
||||
for i in 0..1000 {
|
||||
let t = pythagorean_iter.next();
|
||||
assert!(t.is_some());
|
||||
|
||||
let (a, b, c) = t.unwrap();
|
||||
assert_eq!(a * a + b * b, c * c);
|
||||
|
||||
if i < pythagoreans.len() {
|
||||
assert_eq!(pythagoreans[i], (a, b, c))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user