1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.revwalk;
12
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNull;
15 import static org.junit.Assert.assertSame;
16
17 import java.util.ArrayList;
18
19 import org.junit.Test;
20
21 public class FIFORevQueueTest extends RevQueueTestCase<FIFORevQueue> {
22 @Override
23 protected FIFORevQueue create() {
24 return new FIFORevQueue();
25 }
26
27 @Override
28 @Test
29 public void testEmpty() throws Exception {
30 super.testEmpty();
31 assertEquals(0, q.outputType());
32 }
33
34 @Test
35 public void testCloneEmpty() throws Exception {
36 q = new FIFORevQueue(AbstractRevQueue.EMPTY_QUEUE);
37 assertNull(q.next());
38 }
39
40 @Test
41 public void testAddLargeBlocks() throws Exception {
42 final ArrayList<RevCommit> lst = new ArrayList<>();
43 for (int i = 0; i < 3 * BlockRevQueue.Block.BLOCK_SIZE; i++) {
44 final RevCommit c = commit();
45 lst.add(c);
46 q.add(c);
47 }
48 for (int i = 0; i < lst.size(); i++)
49 assertSame(lst.get(i), q.next());
50 }
51
52 @Test
53 public void testUnpopAtFront() throws Exception {
54 final RevCommit a = commit();
55 final RevCommit b = commit();
56 final RevCommit c = commit();
57
58 q.add(a);
59 q.unpop(b);
60 q.unpop(c);
61
62 assertSame(c, q.next());
63 assertSame(b, q.next());
64 assertSame(a, q.next());
65 }
66 }