30 lines
888 B
Rust
30 lines
888 B
Rust
#[cfg(test)]
|
|
mod tests {
|
|
use pyority_queue::backing::pure::{BinaryHeap, PureBacking};
|
|
|
|
#[test]
|
|
fn test_pure_binary_heap_manual_creation() {
|
|
let mut heap = BinaryHeap::new();
|
|
heap.add(4);
|
|
heap.add(-3);
|
|
heap.add(6);
|
|
heap.add(1);
|
|
assert_eq!(heap.len(), 4);
|
|
assert_eq!(heap.pop(), Some(-3));
|
|
assert_eq!(heap.pop(), Some(1));
|
|
assert_eq!(heap.pop(), Some(4));
|
|
assert_eq!(heap.pop(), Some(6));
|
|
assert_eq!(heap.pop(), None);
|
|
}
|
|
|
|
#[test]
|
|
fn test_pure_binary_heap_from_iter() {
|
|
let mut heap = BinaryHeap::from_iter(vec![7, 3, 6, 9]);
|
|
assert_eq!(heap.len(), 4);
|
|
assert_eq!(heap.pop(), Some(3));
|
|
assert_eq!(heap.pop(), Some(6));
|
|
assert_eq!(heap.pop(), Some(7));
|
|
assert_eq!(heap.pop(), Some(9));
|
|
assert_eq!(heap.pop(), None);
|
|
}
|
|
}
|