Skip to content

Commit

Permalink
Test shift_insert that moves
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Feb 11, 2024
1 parent 5debe73 commit 8c206ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ fn shift_insert() {
for (i, k) in (0..insert.len()).zip(map.keys()) {
assert_eq!(map.get_index(i).unwrap().0, k);
}

// "insert" that moves an existing entry
map.shift_insert(0, insert[0], ());
assert_eq!(map.keys().count(), insert.len());
assert_eq!(insert[0], map.keys()[0]);
for (a, b) in insert[1..].iter().rev().zip(map.keys().skip(1)) {
assert_eq!(a, b);
}
}

#[test]
Expand Down
8 changes: 8 additions & 0 deletions src/set/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ fn shift_insert() {
for (i, v) in (0..insert.len()).zip(set.iter()) {
assert_eq!(set.get_index(i).unwrap(), v);
}

// "insert" that moves an existing entry
set.shift_insert(0, insert[0]);
assert_eq!(set.iter().count(), insert.len());
assert_eq!(insert[0], set[0]);
for (a, b) in insert[1..].iter().rev().zip(set.iter().skip(1)) {
assert_eq!(a, b);
}
}

#[test]
Expand Down

0 comments on commit 8c206ef

Please sign in to comment.