-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathTest.java
More file actions
24 lines (21 loc) · 942 Bytes
/
Test.java
File metadata and controls
24 lines (21 loc) · 942 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
package strq;
public class Test {
public static void main(String[] args) {
StringQueue queue = null; // FIXME: Use an instance of your SimpleStringQueue.
queue.enqueue("Hello, world!");
queue.enqueue(" ");
queue.enqueue("This is a test.");
if (queue.length() != 30) throw new AssertionError();
String s = queue.dequeue(10);
if (queue.length() != 20) throw new AssertionError();
if (!s.equals("Hello, wor")) throw new AssertionError();
s = queue.dequeue(10);
if (queue.length() != 10) throw new AssertionError();
if (!s.equals("ld! This ")) throw new AssertionError();
queue.enqueue(" All done.");
if (queue.length() != 21) throw new AssertionError();
s = queue.dequeue(21);
if (queue.length() != 0) throw new AssertionError();
if (!s.equals("is a test. All done.")) throw new AssertionError();
}
}