Skip to content

Commit

Permalink
Test try variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianmarco Garrisi committed Aug 9, 2024
1 parent 56fe3fb commit 3530611
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/double_priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,28 @@ mod doublepq_tests {
assert_eq!(queue.capacity(), 100);
}

#[test]
fn try_reserve() {
use std::collections::hash_map::RandomState;
let mut queue = DoublePriorityQueue::<i32, i32, RandomState>::default();

queue.try_reserve(100).unwrap();

assert_eq!(queue.len(), 0);
assert!(queue.capacity() >= 100);
}

#[test]
fn try_reserve_exact() {
use std::collections::hash_map::RandomState;
let mut queue = DoublePriorityQueue::<i32, i32, RandomState>::default();

queue.try_reserve_exact(100).unwrap();

assert_eq!(queue.len(), 0);
assert_eq!(queue.capacity(), 100);
}

#[test]
fn extend() {
let mut pq = DoublePriorityQueue::new();
Expand Down
22 changes: 22 additions & 0 deletions tests/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,28 @@ mod pqueue_tests {
assert_eq!(queue.capacity(), 100);
}

#[test]
fn try_reserve() {
use std::collections::hash_map::RandomState;
let mut queue = PriorityQueue::<i32, i32, RandomState>::default();

queue.try_reserve(100).unwrap();

assert_eq!(queue.len(), 0);
assert!(queue.capacity() >= 100);
}

#[test]
fn try_reserve_exact() {
use std::collections::hash_map::RandomState;
let mut queue = PriorityQueue::<i32, i32, RandomState>::default();

queue.try_reserve_exact(100).unwrap();

assert_eq!(queue.len(), 0);
assert_eq!(queue.capacity(), 100);
}

#[test]
fn extend() {
let mut pq = PriorityQueue::new();
Expand Down

0 comments on commit 3530611

Please sign in to comment.