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 package org.eclipse.jgit.revwalk;
45
46 import static org.junit.Assert.assertEquals;
47 import static org.junit.Assert.assertFalse;
48 import static org.junit.Assert.assertNull;
49
50 import org.junit.Test;
51
52 public class DateRevQueueTest extends RevQueueTestCase<DateRevQueue> {
53 protected DateRevQueue create() {
54 return new DateRevQueue();
55 }
56
57 @Test
58 public void testEmpty() throws Exception {
59 super.testEmpty();
60 assertNull(q.peek());
61 assertEquals(Generator.SORT_COMMIT_TIME_DESC, q.outputType());
62 }
63
64 @Test
65 public void testCloneEmpty() throws Exception {
66 q = new DateRevQueue(AbstractRevQueue.EMPTY_QUEUE);
67 assertNull(q.next());
68 }
69
70 @Test
71 public void testInsertOutOfOrder() throws Exception {
72 final RevCommit a = parseBody(commit());
73 final RevCommit b = parseBody(commit(10, a));
74 final RevCommit c1 = parseBody(commit(5, b));
75 final RevCommit c2 = parseBody(commit(-50, b));
76
77 q.add(c2);
78 q.add(a);
79 q.add(b);
80 q.add(c1);
81
82 assertCommit(c1, q.next());
83 assertCommit(b, q.next());
84 assertCommit(a, q.next());
85 assertCommit(c2, q.next());
86 assertNull(q.next());
87 }
88
89 @Test
90 public void testInsertTie() throws Exception {
91 final RevCommit a = parseBody(commit());
92 final RevCommit b = parseBody(commit(0, a));
93 {
94 q = create();
95 q.add(a);
96 q.add(b);
97
98 assertCommit(a, q.next());
99 assertCommit(b, q.next());
100 assertNull(q.next());
101 }
102 {
103 q = create();
104 q.add(b);
105 q.add(a);
106
107 assertCommit(b, q.next());
108 assertCommit(a, q.next());
109 assertNull(q.next());
110 }
111 }
112
113 @Test
114 public void testCloneFIFO() throws Exception {
115 final RevCommit a = parseBody(commit());
116 final RevCommit b = parseBody(commit(200, a));
117 final RevCommit c = parseBody(commit(200, b));
118
119 final FIFORevQueue src = new FIFORevQueue();
120 src.add(a);
121 src.add(b);
122 src.add(c);
123
124 q = new DateRevQueue(src);
125 assertFalse(q.everbodyHasFlag(RevWalk.UNINTERESTING));
126 assertFalse(q.anybodyHasFlag(RevWalk.UNINTERESTING));
127 assertCommit(c, q.peek());
128 assertCommit(c, q.peek());
129
130 assertCommit(c, q.next());
131 assertCommit(b, q.next());
132 assertCommit(a, q.next());
133 assertNull(q.next());
134 }
135 }