Skip to content

Commit 3d1d290

Browse files
committed
Test get_disjoint_mut with both head and tail slices
1 parent 293b85f commit 3d1d290

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/map/tests.rs

+47
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,36 @@ fn disjoint_mut_multi_success() {
980980
);
981981
}
982982

983+
#[test]
984+
fn disjoint_mut_multi_success_double_ended() {
985+
let mut map: RingMap<u32, u32> = RingMap::default();
986+
map.push_back(2, 200);
987+
map.push_back(3, 300);
988+
map.push_back(4, 400);
989+
map.push_front(1, 100);
990+
{
991+
let (head, tail) = map.as_mut_slices();
992+
assert!(!head.is_empty() && !tail.is_empty());
993+
}
994+
assert_eq!(
995+
map.get_disjoint_mut([&1, &2]),
996+
[Some(&mut 100), Some(&mut 200)]
997+
);
998+
assert_eq!(
999+
map.get_disjoint_mut([&1, &3]),
1000+
[Some(&mut 100), Some(&mut 300)]
1001+
);
1002+
assert_eq!(
1003+
map.get_disjoint_mut([&3, &1, &4, &2]),
1004+
[
1005+
Some(&mut 300),
1006+
Some(&mut 100),
1007+
Some(&mut 400),
1008+
Some(&mut 200)
1009+
]
1010+
);
1011+
}
1012+
9831013
#[test]
9841014
fn disjoint_mut_multi_success_unsized_key() {
9851015
let mut map: RingMap<&'static str, u32> = RingMap::default();
@@ -1091,6 +1121,23 @@ fn disjoint_indices_mut_success() {
10911121
);
10921122
}
10931123

1124+
#[test]
1125+
fn disjoint_indices_mut_success_double_ended() {
1126+
let mut map: RingMap<u32, u32> = RingMap::default();
1127+
map.push_back(1, 10);
1128+
map.push_back(321, 20);
1129+
map.push_front(42, 0o42);
1130+
{
1131+
let (head, tail) = map.as_mut_slices();
1132+
assert!(!head.is_empty() && !tail.is_empty());
1133+
}
1134+
assert_eq!(map.get_disjoint_indices_mut([1]), Ok([(&1, &mut 10)]));
1135+
assert_eq!(
1136+
map.get_disjoint_indices_mut([0, 2]),
1137+
Ok([(&42, &mut 0o42), (&321, &mut 20)])
1138+
);
1139+
}
1140+
10941141
#[test]
10951142
fn disjoint_indices_mut_fail_duplicate() {
10961143
let mut map: RingMap<u32, u32> = RingMap::default();

0 commit comments

Comments
 (0)