You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PackSourceTest.java 2.6KB

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