Skip to content

Commit 503ceda

Browse files
committed
Test that maplike FromIter satisfies uniqueness
1 parent 4b65a86 commit 503ceda

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Diff for: src/libstd/collections/hash/map.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -3138,13 +3138,15 @@ mod test_map {
31383138

31393139
#[test]
31403140
fn test_from_iter() {
3141-
let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
3141+
let xs = [(1, 1), (2, 2), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
31423142

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

31453145
for &(k, v) in &xs {
31463146
assert_eq!(map.get(&k), Some(&v));
31473147
}
3148+
3149+
assert_eq!(map.iter().len(), xs.len() - 1);
31483150
}
31493151

31503152
#[test]

Diff for: src/libstd/collections/hash/set.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1782,13 +1782,15 @@ mod test_set {
17821782

17831783
#[test]
17841784
fn test_from_iter() {
1785-
let xs = [1, 2, 3, 4, 5, 6, 7, 8, 9];
1785+
let xs = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9];
17861786

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

17891789
for x in &xs {
17901790
assert!(set.contains(x));
17911791
}
1792+
1793+
assert_eq!(set.iter().len(), xs.len() - 1);
17921794
}
17931795

17941796
#[test]

0 commit comments

Comments
 (0)