Skip to content

Commit 8651aa0

Browse files
committed
Add test for BTreeMap::clone_from
1 parent f547978 commit 8651aa0

File tree

1 file changed

+20
-0
lines changed
  • src/liballoc/tests/btree

1 file changed

+20
-0
lines changed

src/liballoc/tests/btree/map.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,26 @@ fn test_clone() {
554554
}
555555
}
556556

557+
#[test]
558+
fn test_clone_from() {
559+
let mut map1 = BTreeMap::new();
560+
let size = 30;
561+
562+
for i in 0..size {
563+
map1.insert(i, 10 * i);
564+
let mut map2 = BTreeMap::new();
565+
for j in 0..i {
566+
map2.insert(100 * j + 1, 2 * j + 1);
567+
let mut map1_copy = map2.clone();
568+
map1_copy.clone_from(&map1);
569+
assert_eq!(map1_copy, map1);
570+
let mut map2_copy = map1.clone();
571+
map2_copy.clone_from(&map2);
572+
assert_eq!(map2_copy, map2);
573+
}
574+
}
575+
}
576+
557577
#[test]
558578
#[allow(dead_code)]
559579
fn test_variance() {

0 commit comments

Comments
 (0)