diff --git a/tests/double_priority_queue.rs b/tests/double_priority_queue.rs index 4d3b280..85c699a 100644 --- a/tests/double_priority_queue.rs +++ b/tests/double_priority_queue.rs @@ -343,6 +343,25 @@ mod doublepq_tests { } } + #[test] + fn drain() { + use std::collections::hash_map::RandomState; + let mut queue = DoublePriorityQueue::::default(); + + for i in 0..7 { + queue.push(i, i); + } + + let previous_capacity = queue.capacity(); + queue.drain(); + + assert_eq!(queue.len(), 0); + assert_eq!(queue.capacity(), previous_capacity); + assert_eq!(queue.pop_min(), None); + assert_eq!(queue.pop_max(), None); + } + + #[test] fn extend() { let mut pq = DoublePriorityQueue::new(); diff --git a/tests/priority_queue.rs b/tests/priority_queue.rs index 9acf62d..127591f 100644 --- a/tests/priority_queue.rs +++ b/tests/priority_queue.rs @@ -327,6 +327,23 @@ mod pqueue_tests { } } + #[test] + fn drain() { + use std::collections::hash_map::RandomState; + let mut queue = PriorityQueue::::default(); + + for i in 0..7 { + queue.push(i, i); + } + + let previous_capacity = queue.capacity(); + queue.drain(); + + assert_eq!(queue.len(), 0); + assert_eq!(queue.capacity(), previous_capacity); + assert_eq!(queue.pop(), None); + } + #[test] fn extend() { let mut pq = PriorityQueue::new();