aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefListTest.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefListTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefListTest.java
index d124d7365c..9981bd6514 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefListTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefListTest.java
@@ -128,6 +128,41 @@ public class RefListTest {
}
@Test
+ public void testBuilder_AddThenDedupe() {
+ RefList.Builder<Ref> builder = new RefList.Builder<>(1);
+ builder.add(REF_B);
+ builder.add(REF_A);
+ builder.add(REF_A);
+ builder.add(REF_B);
+ builder.add(REF_c);
+
+ builder.sort();
+ builder.dedupe((a, b) -> b);
+ RefList<Ref> list = builder.toRefList();
+
+ assertEquals(3, list.size());
+ assertSame(REF_A, list.get(0));
+ assertSame(REF_B, list.get(1));
+ assertSame(REF_c, list.get(2));
+ }
+
+ @Test
+ public void testBuilder_AddThenDedupe_Border() {
+ RefList.Builder<Ref> builder = new RefList.Builder<>(1);
+ builder.sort();
+ builder.dedupe((a, b) -> b);
+ RefList<Ref> list = builder.toRefList();
+ assertTrue(list.isEmpty());
+
+ builder = new RefList.Builder<>(1);
+ builder.add(REF_A);
+ builder.sort();
+ builder.dedupe((a, b) -> b);
+ list = builder.toRefList();
+ assertEquals(1, list.size());
+ }
+
+ @Test
public void testBuilder_AddAll() {
RefList.Builder<Ref> builder = new RefList.Builder<>(1);
Ref[] src = { REF_A, REF_B, REF_c, REF_A };