Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianmarco Garrisi committed Aug 9, 2024
1 parent a350eb3 commit 83a5dab
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/double_priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,25 @@ mod doublepq_tests {
}
}

#[test]
fn drain() {
use std::collections::hash_map::RandomState;
let mut queue = DoublePriorityQueue::<i32, i32, RandomState>::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();
Expand Down
17 changes: 17 additions & 0 deletions tests/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,23 @@ mod pqueue_tests {
}
}

#[test]
fn drain() {
use std::collections::hash_map::RandomState;
let mut queue = PriorityQueue::<i32, i32, RandomState>::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();
Expand Down

0 comments on commit 83a5dab

Please sign in to comment.