28 lines
837 B
Rust
28 lines
837 B
Rust
#[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);
|
|
}
|
|
}
|