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