View Javadoc
1   /*
2    * Copyright (C) 2018, Google LLC. and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  
11  package org.eclipse.jgit.internal.storage.dfs;
12  
13  import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.COMPACT;
14  import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.DEFAULT_COMPARATOR;
15  import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.GC;
16  import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.GC_REST;
17  import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.GC_TXN;
18  import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.INSERT;
19  import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.RECEIVE;
20  import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.UNREACHABLE_GARBAGE;
21  import static org.junit.Assert.assertEquals;
22  
23  import org.junit.Test;
24  
25  public class PackSourceTest {
26  	@Test
27  	public void defaultComaprator() throws Exception {
28  		assertEquals(0, DEFAULT_COMPARATOR.compare(INSERT, INSERT));
29  		assertEquals(0, DEFAULT_COMPARATOR.compare(RECEIVE, RECEIVE));
30  		assertEquals(0, DEFAULT_COMPARATOR.compare(COMPACT, COMPACT));
31  		assertEquals(0, DEFAULT_COMPARATOR.compare(GC, GC));
32  		assertEquals(0, DEFAULT_COMPARATOR.compare(GC_REST, GC_REST));
33  		assertEquals(0, DEFAULT_COMPARATOR.compare(GC_TXN, GC_TXN));
34  		assertEquals(0, DEFAULT_COMPARATOR.compare(UNREACHABLE_GARBAGE, UNREACHABLE_GARBAGE));
35  
36  		assertEquals(0, DEFAULT_COMPARATOR.compare(INSERT, RECEIVE));
37  		assertEquals(0, DEFAULT_COMPARATOR.compare(RECEIVE, INSERT));
38  
39  		assertEquals(-1, DEFAULT_COMPARATOR.compare(INSERT, COMPACT));
40  		assertEquals(1, DEFAULT_COMPARATOR.compare(COMPACT, INSERT));
41  
42  		assertEquals(-1, DEFAULT_COMPARATOR.compare(RECEIVE, COMPACT));
43  		assertEquals(1, DEFAULT_COMPARATOR.compare(COMPACT, RECEIVE));
44  
45  		assertEquals(-1, DEFAULT_COMPARATOR.compare(COMPACT, GC));
46  		assertEquals(1, DEFAULT_COMPARATOR.compare(GC, COMPACT));
47  
48  		assertEquals(-1, DEFAULT_COMPARATOR.compare(GC, GC_REST));
49  		assertEquals(1, DEFAULT_COMPARATOR.compare(GC_REST, GC));
50  
51  		assertEquals(-1, DEFAULT_COMPARATOR.compare(GC_REST, GC_TXN));
52  		assertEquals(1, DEFAULT_COMPARATOR.compare(GC_TXN, GC_REST));
53  
54  		assertEquals(-1, DEFAULT_COMPARATOR.compare(GC_TXN, UNREACHABLE_GARBAGE));
55  		assertEquals(1, DEFAULT_COMPARATOR.compare(UNREACHABLE_GARBAGE, GC_TXN));
56  	}
57  }