libcollections: Use iterators instead of old-style loops.
This commit is contained in:
parent
1eb4ce0297
commit
a9d112b3e5
2 changed files with 14 additions and 38 deletions
|
@ -1426,18 +1426,14 @@ mod tests {
|
|||
fn test_small_clear() {
|
||||
let mut b = Bitv::with_capacity(14, true);
|
||||
b.clear();
|
||||
BitvSet::from_bitv(b).iter().advance(|i| {
|
||||
fail!("found 1 at {:?}", i)
|
||||
});
|
||||
assert!(b.none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_big_clear() {
|
||||
let mut b = Bitv::with_capacity(140, true);
|
||||
b.clear();
|
||||
BitvSet::from_bitv(b).iter().advance(|i| {
|
||||
fail!("found 1 at {:?}", i)
|
||||
});
|
||||
assert!(b.none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1494,14 +1490,9 @@ mod tests {
|
|||
assert!(b.insert(5));
|
||||
assert!(b.insert(3));
|
||||
|
||||
let mut i = 0;
|
||||
let expected = [3, 5, 11, 77];
|
||||
a.intersection(&b).advance(|x| {
|
||||
assert_eq!(x, expected[i]);
|
||||
i += 1;
|
||||
true
|
||||
});
|
||||
assert_eq!(i, expected.len());
|
||||
let actual = a.intersection(&b).collect::<Vec<uint>>();
|
||||
assert_eq!(actual.as_slice(), expected.as_slice());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1518,14 +1509,9 @@ mod tests {
|
|||
assert!(b.insert(3));
|
||||
assert!(b.insert(200));
|
||||
|
||||
let mut i = 0;
|
||||
let expected = [1, 5, 500];
|
||||
a.difference(&b).advance(|x| {
|
||||
assert_eq!(x, expected[i]);
|
||||
i += 1;
|
||||
true
|
||||
});
|
||||
assert_eq!(i, expected.len());
|
||||
let actual = a.difference(&b).collect::<Vec<uint>>();
|
||||
assert_eq!(actual.as_slice(), expected.as_slice());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1544,14 +1530,9 @@ mod tests {
|
|||
assert!(b.insert(14));
|
||||
assert!(b.insert(220));
|
||||
|
||||
let mut i = 0;
|
||||
let expected = [1, 5, 11, 14, 220];
|
||||
a.symmetric_difference(&b).advance(|x| {
|
||||
assert_eq!(x, expected[i]);
|
||||
i += 1;
|
||||
true
|
||||
});
|
||||
assert_eq!(i, expected.len());
|
||||
let actual = a.symmetric_difference(&b).collect::<Vec<uint>>();
|
||||
assert_eq!(actual.as_slice(), expected.as_slice());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1573,14 +1554,9 @@ mod tests {
|
|||
assert!(b.insert(13));
|
||||
assert!(b.insert(19));
|
||||
|
||||
let mut i = 0;
|
||||
let expected = [1, 3, 5, 9, 11, 13, 19, 24, 160];
|
||||
a.union(&b).advance(|x| {
|
||||
assert_eq!(x, expected[i]);
|
||||
i += 1;
|
||||
true
|
||||
});
|
||||
assert_eq!(i, expected.len());
|
||||
let actual = a.union(&b).collect::<Vec<uint>>();
|
||||
assert_eq!(actual.as_slice(), expected.as_slice());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1770,7 +1770,7 @@ mod test_set {
|
|||
#[test]
|
||||
fn test_intersection() {
|
||||
fn check_intersection(a: &[int], b: &[int], expected: &[int]) {
|
||||
check(a, b, expected, |x, y, f| x.intersection(y).advance(f))
|
||||
check(a, b, expected, |x, y, f| x.intersection(y).all(f))
|
||||
}
|
||||
|
||||
check_intersection([], [], []);
|
||||
|
@ -1786,7 +1786,7 @@ mod test_set {
|
|||
#[test]
|
||||
fn test_difference() {
|
||||
fn check_difference(a: &[int], b: &[int], expected: &[int]) {
|
||||
check(a, b, expected, |x, y, f| x.difference(y).advance(f))
|
||||
check(a, b, expected, |x, y, f| x.difference(y).all(f))
|
||||
}
|
||||
|
||||
check_difference([], [], []);
|
||||
|
@ -1804,7 +1804,7 @@ mod test_set {
|
|||
fn test_symmetric_difference() {
|
||||
fn check_symmetric_difference(a: &[int], b: &[int],
|
||||
expected: &[int]) {
|
||||
check(a, b, expected, |x, y, f| x.symmetric_difference(y).advance(f))
|
||||
check(a, b, expected, |x, y, f| x.symmetric_difference(y).all(f))
|
||||
}
|
||||
|
||||
check_symmetric_difference([], [], []);
|
||||
|
@ -1819,7 +1819,7 @@ mod test_set {
|
|||
fn test_union() {
|
||||
fn check_union(a: &[int], b: &[int],
|
||||
expected: &[int]) {
|
||||
check(a, b, expected, |x, y, f| x.union(y).advance(f))
|
||||
check(a, b, expected, |x, y, f| x.union(y).all(f))
|
||||
}
|
||||
|
||||
check_union([], [], []);
|
||||
|
|
Loading…
Reference in a new issue