Skip to content

Commit

Permalink
Add test coverage for removing from the sublist of a sublist.
Browse files Browse the repository at this point in the history
  • Loading branch information
motlin committed Mar 10, 2016
1 parent d1dc3f6 commit 1f7b3c1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015 Goldman Sachs.
* Copyright (c) 2016 Goldman Sachs.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompany this distribution.
Expand Down Expand Up @@ -77,4 +77,24 @@ default void MutableList_sortThis_comparator()
assertSame(mutableList, sortedList);
assertEquals(Lists.immutable.with(5, 4, 3, 2, 1), sortedList);
}

@Test
default void MutableList_subList_subList_remove()
{
MutableList<String> list = this.newWith("A", "B", "C", "D");
MutableList<String> sublist = list.subList(0, 3);
MutableList<String> sublist2 = sublist.subList(0, 2);

assertEquals(Lists.immutable.with("A", "B", "C"), sublist);
assertEquals(Lists.immutable.with("A", "B"), sublist2);

sublist2.add("X");

assertEquals(Lists.immutable.with("A", "B", "X", "C"), sublist);
assertEquals(Lists.immutable.with("A", "B", "X"), sublist2);

assertEquals("B", sublist2.remove(1));
assertEquals(Lists.immutable.with("A", "X", "C"), sublist);
assertEquals(Lists.immutable.with("A", "X"), sublist2);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015 Goldman Sachs.
* Copyright (c) 2016 Goldman Sachs.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompany this distribution.
Expand All @@ -17,6 +17,8 @@
import org.eclipse.collections.test.list.UnmodifiableListTestCase;
import org.junit.Test;

import static org.eclipse.collections.impl.test.Verify.assertThrows;

public interface UnmodifiableMutableListTestCase extends UnmodifiableMutableCollectionTestCase, UnmodifiableListTestCase, MutableListTestCase
{
@Override
Expand Down Expand Up @@ -47,4 +49,11 @@ default void MutableList_sortThis_comparator()
{
this.newWith(5, 1, 4, 2, 3).sortThis(Comparators.reverseNaturalOrder());
}

@Override
@Test
default void MutableList_subList_subList_remove()
{
assertThrows(UnsupportedOperationException.class, () -> this.newWith().subList(0, 0).remove(new Object()));
}
}

0 comments on commit 1f7b3c1

Please sign in to comment.