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.internal.storage.dfs;
45
46 import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.COMPACT;
47 import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.DEFAULT_COMPARATOR;
48 import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.GC;
49 import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.GC_REST;
50 import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.GC_TXN;
51 import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.INSERT;
52 import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.RECEIVE;
53 import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.UNREACHABLE_GARBAGE;
54 import static org.junit.Assert.assertEquals;
55
56 import org.junit.Test;
57
58 public class PackSourceTest {
59 @Test
60 public void defaultComaprator() throws Exception {
61 assertEquals(0, DEFAULT_COMPARATOR.compare(INSERT, INSERT));
62 assertEquals(0, DEFAULT_COMPARATOR.compare(RECEIVE, RECEIVE));
63 assertEquals(0, DEFAULT_COMPARATOR.compare(COMPACT, COMPACT));
64 assertEquals(0, DEFAULT_COMPARATOR.compare(GC, GC));
65 assertEquals(0, DEFAULT_COMPARATOR.compare(GC_REST, GC_REST));
66 assertEquals(0, DEFAULT_COMPARATOR.compare(GC_TXN, GC_TXN));
67 assertEquals(0, DEFAULT_COMPARATOR.compare(UNREACHABLE_GARBAGE, UNREACHABLE_GARBAGE));
68
69 assertEquals(0, DEFAULT_COMPARATOR.compare(INSERT, RECEIVE));
70 assertEquals(0, DEFAULT_COMPARATOR.compare(RECEIVE, INSERT));
71
72 assertEquals(-1, DEFAULT_COMPARATOR.compare(INSERT, COMPACT));
73 assertEquals(1, DEFAULT_COMPARATOR.compare(COMPACT, INSERT));
74
75 assertEquals(-1, DEFAULT_COMPARATOR.compare(RECEIVE, COMPACT));
76 assertEquals(1, DEFAULT_COMPARATOR.compare(COMPACT, RECEIVE));
77
78 assertEquals(-1, DEFAULT_COMPARATOR.compare(COMPACT, GC));
79 assertEquals(1, DEFAULT_COMPARATOR.compare(GC, COMPACT));
80
81 assertEquals(-1, DEFAULT_COMPARATOR.compare(GC, GC_REST));
82 assertEquals(1, DEFAULT_COMPARATOR.compare(GC_REST, GC));
83
84 assertEquals(-1, DEFAULT_COMPARATOR.compare(GC_REST, GC_TXN));
85 assertEquals(1, DEFAULT_COMPARATOR.compare(GC_TXN, GC_REST));
86
87 assertEquals(-1, DEFAULT_COMPARATOR.compare(GC_TXN, UNREACHABLE_GARBAGE));
88 assertEquals(1, DEFAULT_COMPARATOR.compare(UNREACHABLE_GARBAGE, GC_TXN));
89 }
90 }