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.INSERT;
18  import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.RECEIVE;
19  import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.UNREACHABLE_GARBAGE;
20  import static org.junit.Assert.assertEquals;
21  
22  import org.junit.Test;
23  
24  public class PackSourceTest {
25  	@Test
26  	public void defaultComaprator() throws Exception {
27  		assertEquals(0, DEFAULT_COMPARATOR.compare(INSERT, INSERT));
28  		assertEquals(0, DEFAULT_COMPARATOR.compare(RECEIVE, RECEIVE));
29  		assertEquals(0, DEFAULT_COMPARATOR.compare(COMPACT, COMPACT));
30  		assertEquals(0, DEFAULT_COMPARATOR.compare(GC, GC));
31  		assertEquals(0, DEFAULT_COMPARATOR.compare(GC_REST, GC_REST));
32  		assertEquals(0, DEFAULT_COMPARATOR.compare(UNREACHABLE_GARBAGE, UNREACHABLE_GARBAGE));
33  
34  		assertEquals(0, DEFAULT_COMPARATOR.compare(INSERT, RECEIVE));
35  		assertEquals(0, DEFAULT_COMPARATOR.compare(RECEIVE, INSERT));
36  
37  		assertEquals(-1, DEFAULT_COMPARATOR.compare(INSERT, COMPACT));
38  		assertEquals(1, DEFAULT_COMPARATOR.compare(COMPACT, INSERT));
39  
40  		assertEquals(-1, DEFAULT_COMPARATOR.compare(RECEIVE, COMPACT));
41  		assertEquals(1, DEFAULT_COMPARATOR.compare(COMPACT, RECEIVE));
42  
43  		assertEquals(-1, DEFAULT_COMPARATOR.compare(COMPACT, GC));
44  		assertEquals(1, DEFAULT_COMPARATOR.compare(GC, COMPACT));
45  
46  		assertEquals(-1, DEFAULT_COMPARATOR.compare(GC, GC_REST));
47  		assertEquals(1, DEFAULT_COMPARATOR.compare(GC_REST, GC));
48  	}
49  }