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.

MaxCountRevFilterTest.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.MaxCountRevFilter;
  13. import org.junit.Test;
  14. public class MaxCountRevFilterTest extends RevWalkTestCase {
  15. @Test
  16. public void testMaxCountRevFilter() throws Exception {
  17. final RevCommit a = commit();
  18. final RevCommit b = commit(a);
  19. final RevCommit c1 = commit(b);
  20. final RevCommit c2 = commit(b);
  21. final RevCommit d = commit(c1, c2);
  22. final RevCommit e = commit(d);
  23. rw.reset();
  24. rw.setRevFilter(MaxCountRevFilter.create(3));
  25. markStart(e);
  26. assertCommit(e, rw.next());
  27. assertCommit(d, rw.next());
  28. assertCommit(c2, rw.next());
  29. assertNull(rw.next());
  30. rw.reset();
  31. rw.setRevFilter(MaxCountRevFilter.create(0));
  32. markStart(e);
  33. assertNull(rw.next());
  34. }
  35. @Test
  36. public void testMaxCountRevFilter0() throws Exception {
  37. final RevCommit a = commit();
  38. final RevCommit b = commit(a);
  39. rw.reset();
  40. rw.setRevFilter(MaxCountRevFilter.create(0));
  41. markStart(b);
  42. assertNull(rw.next());
  43. }
  44. }