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.

FIFORevQueueTest.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2009, Google Inc. 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.revwalk;
  11. import static org.junit.Assert.assertEquals;
  12. import static org.junit.Assert.assertNull;
  13. import static org.junit.Assert.assertSame;
  14. import java.util.ArrayList;
  15. import org.junit.Test;
  16. public class FIFORevQueueTest extends RevQueueTestCase<FIFORevQueue> {
  17. @Override
  18. protected FIFORevQueue create() {
  19. return new FIFORevQueue();
  20. }
  21. @Override
  22. @Test
  23. public void testEmpty() throws Exception {
  24. super.testEmpty();
  25. assertEquals(0, q.outputType());
  26. }
  27. @Test
  28. public void testCloneEmpty() throws Exception {
  29. q = new FIFORevQueue(AbstractRevQueue.EMPTY_QUEUE);
  30. assertNull(q.next());
  31. }
  32. @Test
  33. public void testAddLargeBlocks() throws Exception {
  34. final ArrayList<RevCommit> lst = new ArrayList<>();
  35. for (int i = 0; i < 3 * BlockRevQueue.Block.BLOCK_SIZE; i++) {
  36. final RevCommit c = commit();
  37. lst.add(c);
  38. q.add(c);
  39. }
  40. for (int i = 0; i < lst.size(); i++)
  41. assertSame(lst.get(i), q.next());
  42. }
  43. @Test
  44. public void testUnpopAtFront() throws Exception {
  45. final RevCommit a = commit();
  46. final RevCommit b = commit();
  47. final RevCommit c = commit();
  48. q.add(a);
  49. q.unpop(b);
  50. q.unpop(c);
  51. assertSame(c, q.next());
  52. assertSame(b, q.next());
  53. assertSame(a, q.next());
  54. }
  55. }