Skip to content

Commit 3af1d20

Browse files
blake2-ppcthestinger
blake2-ppc
authored andcommitted
std::hashmap: Add test_iterate for HashSet
1 parent 080d498 commit 3af1d20

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/libstd/hashmap.rs

+14
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,7 @@ mod test_set {
952952
use super::*;
953953
use container::{Container, Map, Set};
954954
use vec;
955+
use uint;
955956

956957
#[test]
957958
fn test_disjoint() {
@@ -1004,6 +1005,19 @@ mod test_set {
10041005
assert!(b.is_superset(&a));
10051006
}
10061007

1008+
#[test]
1009+
fn test_iterate() {
1010+
let mut a = HashSet::new();
1011+
for uint::range(0, 32) |i| {
1012+
assert!(a.insert(i));
1013+
}
1014+
let mut observed = 0;
1015+
for a.iter().advance |k| {
1016+
observed |= (1 << *k);
1017+
}
1018+
assert_eq!(observed, 0xFFFF_FFFF);
1019+
}
1020+
10071021
#[test]
10081022
fn test_intersection() {
10091023
let mut a = HashSet::new();

0 commit comments

Comments
 (0)