Skip to content

Commit 8f05f02

Browse files
committed
Add test for BTreeMap::clone_from
1 parent 9001b1e commit 8f05f02

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

+20
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,26 @@ fn test_clone() {
552552
}
553553
}
554554

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

0 commit comments

Comments
 (0)