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