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.

RevQueueTestCase.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (C) 2009-2010, 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.assertFalse;
  12. import static org.junit.Assert.assertNull;
  13. import static org.junit.Assert.assertTrue;
  14. import org.junit.Test;
  15. public abstract class RevQueueTestCase<T extends AbstractRevQueue> extends
  16. RevWalkTestCase {
  17. protected T q;
  18. @Override
  19. public void setUp() throws Exception {
  20. super.setUp();
  21. q = create();
  22. }
  23. protected abstract T create();
  24. @Test
  25. public void testEmpty() throws Exception {
  26. assertNull(q.next());
  27. assertTrue(q.everbodyHasFlag(RevWalk.UNINTERESTING));
  28. assertFalse(q.anybodyHasFlag(RevWalk.UNINTERESTING));
  29. }
  30. @Test
  31. public void testClear() throws Exception {
  32. final RevCommit a = parseBody(commit());
  33. final RevCommit b = parseBody(commit(a));
  34. q.add(a);
  35. q.add(b);
  36. q.clear();
  37. assertNull(q.next());
  38. }
  39. @Test
  40. public void testHasFlags() throws Exception {
  41. final RevCommit a = parseBody(commit());
  42. final RevCommit b = parseBody(commit(a));
  43. q.add(a);
  44. q.add(b);
  45. assertFalse(q.everbodyHasFlag(RevWalk.UNINTERESTING));
  46. assertFalse(q.anybodyHasFlag(RevWalk.UNINTERESTING));
  47. a.flags |= RevWalk.UNINTERESTING;
  48. assertFalse(q.everbodyHasFlag(RevWalk.UNINTERESTING));
  49. assertTrue(q.anybodyHasFlag(RevWalk.UNINTERESTING));
  50. b.flags |= RevWalk.UNINTERESTING;
  51. assertTrue(q.everbodyHasFlag(RevWalk.UNINTERESTING));
  52. assertTrue(q.anybodyHasFlag(RevWalk.UNINTERESTING));
  53. }
  54. }