-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuperDequeTest.java
More file actions
93 lines (82 loc) · 2.64 KB
/
SuperDequeTest.java
File metadata and controls
93 lines (82 loc) · 2.64 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
/**
* @author Brianna Penkala
* This is the testing class for SuperDeque
*/
class SuperDequeTest {
/** These are various implementations of SuperDeque that use both stack and queue operations */
private SuperDeque<Integer> superDeque = new SuperDeque<>();
private SuperDeque<Integer> exampleDeque = new SuperDeque<>();
private SuperDeque<Integer> queueExample = new SuperDeque<>();
/** This method sets up the deques to be tested on */
@BeforeEach
public void setUp() {
exampleDeque.push(5);
exampleDeque.push(9);
exampleDeque.push(1);
//"1, 9, 5"
queueExample.enqueue(7);
queueExample.enqueue(8);
queueExample.enqueue(9);
//"7, 8, 9"
}
/** This method tests the getDQLength method */
@Test
void getDQLength() {
assertEquals(4, queueExample.getDQLength());
exampleDeque.push(6);
exampleDeque.push(7);
assertEquals(8, exampleDeque.getDQLength());
}
/** This method tests the push method */
@Test
void push() {
assertEquals("1, 9, 5", exampleDeque.toString());
superDeque.push(4);
superDeque.push(8);
superDeque.push(3);
superDeque.push(7);
//"7, 3, 8, 4"
assertEquals("7, 3, 8, 4", superDeque.toString());
assertEquals("7, 8, 9", queueExample.toString());
}
/** This method tests the pop method */
@Test
void pop() {
assertEquals(1, exampleDeque.pop());
assertEquals(7, queueExample.pop());
}
/** This method tests the peek method */
@Test
void peek() {
assertEquals(1, exampleDeque.peek());
assertEquals(7, queueExample.peek());
}
/** This method tests the enqueue method */
@Test
void enqueue() {
exampleDeque.enqueue(2);
assertEquals("1, 9, 5, 2", exampleDeque.toString());
assertEquals(7, queueExample.peek()); //(item was enqueued onto queueExample, verifying it was added)
}
/** This method tests the dequeue method */
@Test
void dequeue() {
queueExample.dequeue();
assertEquals("8, 9", queueExample.toString());
}
/** This method tests the isEmpty method */
@Test
void isEmpty() {
assertFalse(exampleDeque.isEmpty());
assertFalse(queueExample.isEmpty());
}
/** This method tests the toString method */
@Test
void testToString() {
assertEquals("1, 9, 5", exampleDeque.toString());
assertEquals("7, 8, 9", queueExample.toString());
}
}