Skip to content

Commit

Permalink
Test that maplike FromIter satisfies uniqueness
Browse files Browse the repository at this point in the history
  • Loading branch information
nhynes committed Jul 16, 2019
1 parent 4b65a86 commit 503ceda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3138,13 +3138,15 @@ mod test_map {

#[test]
fn test_from_iter() {
let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
let xs = [(1, 1), (2, 2), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];

let map: HashMap<_, _> = xs.iter().cloned().collect();

for &(k, v) in &xs {
assert_eq!(map.get(&k), Some(&v));
}

assert_eq!(map.iter().len(), xs.len() - 1);
}

#[test]
Expand Down
4 changes: 3 additions & 1 deletion src/libstd/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1782,13 +1782,15 @@ mod test_set {

#[test]
fn test_from_iter() {
let xs = [1, 2, 3, 4, 5, 6, 7, 8, 9];
let xs = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9];

let set: HashSet<_> = xs.iter().cloned().collect();

for x in &xs {
assert!(set.contains(x));
}

assert_eq!(set.iter().len(), xs.len() - 1);
}

#[test]
Expand Down

0 comments on commit 503ceda

Please sign in to comment.