Add rough binary heap test
This commit is contained in:
parent
df7536b82b
commit
b273772722
2 changed files with 29 additions and 1 deletions
|
@ -6,7 +6,7 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[lib]
|
||||
name = "pyority_queue"
|
||||
crate-type = ["cdylib"]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
pyo3 = "0.23.3"
|
||||
|
|
28
tests/pure_binary_heap.rs
Normal file
28
tests/pure_binary_heap.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use pyority_queue::backing::pure::{binary_heap::BinaryHeap, PureBacking};
|
||||
|
||||
#[test]
|
||||
fn test_pure_binary_heap() {
|
||||
let mut heap = BinaryHeap::new();
|
||||
assert_eq!(heap.len(), 0);
|
||||
heap.add(4);
|
||||
assert_eq!(heap.len(), 1);
|
||||
heap.add(-3);
|
||||
assert_eq!(heap.len(), 2);
|
||||
heap.add(6);
|
||||
assert_eq!(heap.len(), 3);
|
||||
heap.add(1);
|
||||
assert_eq!(heap.len(), 4);
|
||||
assert_eq!(heap.pop(), Some(-3));
|
||||
assert_eq!(heap.len(), 3);
|
||||
assert_eq!(heap.pop(), Some(1));
|
||||
assert_eq!(heap.len(), 2);
|
||||
assert_eq!(heap.pop(), Some(4));
|
||||
assert_eq!(heap.len(), 1);
|
||||
assert_eq!(heap.pop(), Some(6));
|
||||
assert_eq!(heap.len(), 0);
|
||||
assert_eq!(heap.pop(), None);
|
||||
assert_eq!(heap.len(), 0);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue