Add unit tests for new BTreeMap::into_{keys,values} methods

This commit is contained in:
Nazım Can Altınova 2020-08-04 22:05:03 +02:00
parent 41dd4ee7ff
commit 29d9233cf6
No known key found for this signature in database
GPG Key ID: 722E786F0729647A
2 changed files with 25 additions and 0 deletions

View File

@ -1461,3 +1461,27 @@ fn test_into_iter_drop_leak_height_1() {
assert_eq!(DROPS.load(Ordering::SeqCst), size);
}
}
#[test]
fn test_into_keys() {
let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')];
let map: BTreeMap<_, _> = vec.into_iter().collect();
let keys: Vec<_> = map.into_keys().collect();
assert_eq!(keys.len(), 3);
assert!(keys.contains(&1));
assert!(keys.contains(&2));
assert!(keys.contains(&3));
}
#[test]
fn test_into_values() {
let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')];
let map: BTreeMap<_, _> = vec.into_iter().collect();
let values: Vec<_> = map.into_values().collect();
assert_eq!(values.len(), 3);
assert!(values.contains(&'a'));
assert!(values.contains(&'b'));
assert!(values.contains(&'c'));
}

View File

@ -4,6 +4,7 @@
#![feature(drain_filter)]
#![feature(exact_size_is_empty)]
#![feature(map_first_last)]
#![feature(map_into_keys_values)]
#![feature(new_uninit)]
#![feature(pattern)]
#![feature(str_split_once)]