Test that maplike FromIter satisfies uniqueness

This commit is contained in:
Nick Hynes 2019-07-16 02:34:00 +00:00
parent 4b65a86eba
commit 503cedac0c
No known key found for this signature in database
GPG Key ID: 23ADC713516FAF1B
2 changed files with 6 additions and 2 deletions

View File

@ -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]

View File

@ -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]