forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneralQueueTest.java
More file actions
45 lines (31 loc) · 1.11 KB
/
GeneralQueueTest.java
File metadata and controls
45 lines (31 loc) · 1.11 KB
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
36
37
38
39
40
41
42
43
44
45
package src.test.java.com.dataStructures;
import org.junit.Assert;
import org.junit.Test;
import src.main.java.com.dataStructures.GeneralQueue;
import src.main.java.com.types.Queue;
public class GeneralQueueTest {
@Test
public void testGeneralQueue() {
Queue<Integer> myQueue = new GeneralQueue<>();
myQueue.add(10);
myQueue.add(20);
myQueue.add(30);
myQueue.add(40);
myQueue.add(50);
Object[] myArray = myQueue.toArray();
Assert.assertEquals(myArray.length, myQueue.size());
myQueue.remove(20);
Assert.assertEquals(myQueue.size(), 4);
Boolean isEmpty = myQueue.isEmpty();
Assert.assertEquals(Boolean.valueOf("false"), Boolean.valueOf(isEmpty));
myQueue.offer(60);
Assert.assertEquals(5, myQueue.size());
int polledElement = myQueue.poll();
Assert.assertEquals(10, polledElement);
int element = myQueue.element();
Assert.assertEquals(30, element);
myQueue.poll();
int peekedElement = myQueue.peek();
Assert.assertEquals(40, peekedElement);
}
}