Skip to content

Commit

Permalink
Add test for BTreeMap::clone_from
Browse files Browse the repository at this point in the history
  • Loading branch information
crgl committed Dec 23, 2019
1 parent f547978 commit 8651aa0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/liballoc/tests/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,26 @@ fn test_clone() {
}
}

#[test]
fn test_clone_from() {
let mut map1 = BTreeMap::new();
let size = 30;

for i in 0..size {
map1.insert(i, 10 * i);
let mut map2 = BTreeMap::new();
for j in 0..i {
map2.insert(100 * j + 1, 2 * j + 1);
let mut map1_copy = map2.clone();
map1_copy.clone_from(&map1);
assert_eq!(map1_copy, map1);
let mut map2_copy = map1.clone();
map2_copy.clone_from(&map2);
assert_eq!(map2_copy, map2);
}
}
}

#[test]
#[allow(dead_code)]
fn test_variance() {
Expand Down

0 comments on commit 8651aa0

Please sign in to comment.