mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
✨ add removeWithAddIf methods
This commit is contained in:
@@ -39,6 +39,23 @@ public class CollUtilTest {
|
||||
Assert.assertFalse(CollUtil.contains(list, s -> s.startsWith("d")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveWithAddIf() {
|
||||
ArrayList<Integer> list = CollUtil.newArrayList(1, 2, 3);
|
||||
ArrayList<Integer> exceptRemovedList = CollUtil.newArrayList(2, 3);
|
||||
ArrayList<Integer> exceptResultList = CollUtil.newArrayList(1);
|
||||
|
||||
ArrayList<Integer> resultList = CollUtil.removeWithAddIf(list, ele -> 1 == ele);
|
||||
Assert.assertEquals(list, exceptRemovedList);
|
||||
Assert.assertEquals(resultList, exceptResultList);
|
||||
|
||||
list = CollUtil.newArrayList(1, 2, 3);
|
||||
resultList = new ArrayList<>();
|
||||
CollUtil.removeWithAddIf(list, resultList, ele -> 1 == ele);
|
||||
Assert.assertEquals(list, exceptRemovedList);
|
||||
Assert.assertEquals(resultList, exceptResultList);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPadLeft() {
|
||||
List<String> srcList = CollUtil.newArrayList();
|
||||
|
Reference in New Issue
Block a user