add method removeAll

This commit is contained in:
2017-11-09 14:32:15 +01:00
parent db6ca1387d
commit 81e1d1f131
2 changed files with 64 additions and 1 deletions

View File

@@ -632,4 +632,34 @@ public class IntListTest {
list.replaceAll(i -> i * 3);
Assert.assertArrayEquals(new int[0], list.toArray());
}
@Test
public void removeAll() {
final IntList list = IntList.of(-2, -1, 0, 1, 2, 3, 4, 5, 6);
final IntList remove = IntList.of(-1, 2, 4, 5);
list.removeAll(remove);
Assert.assertArrayEquals(new int[] { -2, 0, 1, 3, 6 }, list.toArray());
Assert.assertArrayEquals(new int[] { -1, 2, 4, 5 }, remove.toArray());
}
@Test
public void removeEmptyList() {
final IntList list = IntList.of(1, 2, 3, 4, 5, 6);
final IntList remove = new IntList();
list.removeAll(remove);
Assert.assertArrayEquals(new int[] { 1, 2, 3, 4, 5, 6 }, list.toArray());
Assert.assertArrayEquals(new int[] {}, remove.toArray());
}
@Test
public void removeAllFromEmptyList() {
final IntList list = new IntList();
final IntList remove = IntList.of(1);
list.removeAll(remove);
Assert.assertArrayEquals(new int[] {}, list.toArray());
Assert.assertEquals(0, list.size());
}
}