Confirm that densemap len wont panic if lots of retired items

This commit is contained in:
James Wilson
2021-08-10 17:16:33 +01:00
parent 6db7f484ef
commit 4f7b2c8ec5
+34
View File
@@ -131,3 +131,37 @@ where
}
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn len_doesnt_panic_if_lots_of_retired() {
let mut map = DenseMap::<usize,usize>::new();
let id1 = map.add(1);
let id2 = map.add(2);
let id3 = map.add(3);
assert_eq!(map.len(), 3);
map.remove(id1);
map.remove(id2);
assert_eq!(map.len(), 1);
map.remove(id3);
assert_eq!(map.len(), 0);
map.remove(id1);
map.remove(id1);
map.remove(id1);
assert_eq!(map.len(), 0);
}
}