forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreadSafeQueueTest.java
More file actions
35 lines (24 loc) · 876 Bytes
/
ThreadSafeQueueTest.java
File metadata and controls
35 lines (24 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.thealgorithms.datastructures.queues;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
class ThreadSafeQueueTest {
@Test
void testQueueOperations() {
ThreadSafeQueue<Integer> queue = new ThreadSafeQueue<>();
assertTrue(queue.isEmpty());
queue.enqueue(1);
queue.enqueue(2);
assertFalse(queue.isEmpty());
assertEquals(1, queue.dequeue());
assertEquals(2, queue.dequeue());
assertTrue(queue.isEmpty());
}
@Test
void testDequeueEmpty() {
ThreadSafeQueue<Integer> queue = new ThreadSafeQueue<>();
assertNull(queue.dequeue());
}
}