Skip to content

Commit 27af242

Browse files
authored
Added test for the drain method of the LinkedListQueue
1 parent 1d0d356 commit 27af242

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/data_structures/queue_using_singly_linked_list.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,4 +430,19 @@ mod tests {
430430
// Whether to see whether an option of variant Some is returned
431431
assert!(queue.delete(1).is_some());
432432
}
433+
434+
#[test]
435+
fn test_queue_drain() {
436+
let mut queue = LinkedListQueue::default();
437+
438+
// Enqueue some elements
439+
queue.enqueue(1);
440+
queue.enqueue(2);
441+
queue.enqueue(3);
442+
443+
// Then drain the queue
444+
queue.drain();
445+
446+
assert_eq!(queue.len(), 0);
447+
}
433448
}

0 commit comments

Comments
 (0)