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.

SkipRevFilterTest.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (C) 2011, Tomasz Zarna <Tomasz.Zarna@pl.ibm.com> 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.assertNull;
  12. import org.eclipse.jgit.revwalk.filter.SkipRevFilter;
  13. import org.junit.Test;
  14. public class SkipRevFilterTest extends RevWalkTestCase {
  15. @Test
  16. public void testSkipRevFilter() throws Exception {
  17. final RevCommit a = commit();
  18. final RevCommit b1 = commit(a);
  19. final RevCommit b2 = commit(a);
  20. final RevCommit c = commit(b1, b2);
  21. final RevCommit d = commit(c);
  22. rw.reset();
  23. rw.setRevFilter(SkipRevFilter.create(3));
  24. markStart(d);
  25. assertCommit(b1, rw.next());
  26. assertCommit(a, rw.next());
  27. assertNull(rw.next());
  28. }
  29. @Test
  30. public void testSkipRevFilter0() throws Exception {
  31. final RevCommit a = commit();
  32. final RevCommit b = commit(a);
  33. rw.reset();
  34. rw.setRevFilter(SkipRevFilter.create(0));
  35. markStart(b);
  36. assertCommit(b, rw.next());
  37. assertCommit(a, rw.next());
  38. assertNull(rw.next());
  39. }
  40. @Test(expected = IllegalArgumentException.class)
  41. public void testSkipRevFilterNegative() throws Exception {
  42. SkipRevFilter.create(-1);
  43. }
  44. }