mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-03-13 08:40:43 +08:00
@@ -1,29 +1,26 @@
|
||||
package com.thealgorithms.datastructures.queues;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class LinkedQueueTest {
|
||||
@Test
|
||||
public void testQue() {
|
||||
LinkedQueue<Integer> queue = new LinkedQueue<>();
|
||||
for (int i = 1; i < 5; i++)
|
||||
queue.enqueue(i);
|
||||
@Test
|
||||
public void testQue() {
|
||||
LinkedQueue<Integer> queue = new LinkedQueue<>();
|
||||
for (int i = 1; i < 5; i++) queue.enqueue(i);
|
||||
|
||||
assertEquals(queue.peekRear(), 4);
|
||||
assertEquals(queue.peek(2), 2);
|
||||
assertEquals(queue.peekRear(), 4);
|
||||
assertEquals(queue.peek(2), 2);
|
||||
|
||||
assertEquals(queue.peek(4), 4);
|
||||
assertEquals(queue.peek(4), 4);
|
||||
|
||||
final int[] element = { 1 };
|
||||
final int[] element = {1};
|
||||
|
||||
// iterates over all the elements present
|
||||
// as in the form of nodes
|
||||
queue.forEach(integer -> {
|
||||
if (element[0]++ != integer)
|
||||
throw new AssertionError();
|
||||
});
|
||||
}
|
||||
// iterates over all the elements present
|
||||
// as in the form of nodes
|
||||
queue.forEach(integer -> {
|
||||
if (element[0]++ != integer) throw new AssertionError();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class PriorityQueuesTest {
|
||||
myQueue.insert(5);
|
||||
myQueue.insert(3);
|
||||
myQueue.insert(10);
|
||||
|
||||
|
||||
myQueue.remove();
|
||||
Assertions.assertEquals(myQueue.peek(), 5);
|
||||
myQueue.remove();
|
||||
@@ -46,7 +46,7 @@ class PriorityQueuesTest {
|
||||
myQueue.insert(10);
|
||||
Assertions.assertEquals(myQueue.isEmpty(), false);
|
||||
Assertions.assertEquals(myQueue.isFull(), true);
|
||||
|
||||
|
||||
myQueue.remove();
|
||||
Assertions.assertEquals(myQueue.getSize(), 3);
|
||||
Assertions.assertEquals(myQueue.peek(), 5);
|
||||
|
||||
Reference in New Issue
Block a user