1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.revwalk;
12
13 import static org.junit.Assert.assertFalse;
14 import static org.junit.Assert.assertNull;
15 import static org.junit.Assert.assertTrue;
16
17 import org.junit.Test;
18
19 public abstract class RevQueueTestCase<T extends AbstractRevQueue> extends
20 RevWalkTestCase {
21 protected T q;
22
23 @Override
24 public void setUp() throws Exception {
25 super.setUp();
26 q = create();
27 }
28
29 protected abstract T create();
30
31 @Test
32 public void testEmpty() throws Exception {
33 assertNull(q.next());
34 assertTrue(q.everbodyHasFlag(RevWalk.UNINTERESTING));
35 assertFalse(q.anybodyHasFlag(RevWalk.UNINTERESTING));
36 }
37
38 @Test
39 public void testClear() throws Exception {
40 final RevCommit a = parseBody(commit());
41 final RevCommit b = parseBody(commit(a));
42
43 q.add(a);
44 q.add(b);
45 q.clear();
46 assertNull(q.next());
47 }
48
49 @Test
50 public void testHasFlags() throws Exception {
51 final RevCommit a = parseBody(commit());
52 final RevCommit b = parseBody(commit(a));
53
54 q.add(a);
55 q.add(b);
56
57 assertFalse(q.everbodyHasFlag(RevWalk.UNINTERESTING));
58 assertFalse(q.anybodyHasFlag(RevWalk.UNINTERESTING));
59
60 a.flags |= RevWalk.UNINTERESTING;
61 assertFalse(q.everbodyHasFlag(RevWalk.UNINTERESTING));
62 assertTrue(q.anybodyHasFlag(RevWalk.UNINTERESTING));
63
64 b.flags |= RevWalk.UNINTERESTING;
65 assertTrue(q.everbodyHasFlag(RevWalk.UNINTERESTING));
66 assertTrue(q.anybodyHasFlag(RevWalk.UNINTERESTING));
67 }
68 }