This commit is contained in:
Looly
2025-10-15 11:31:06 +08:00
parent b683ade31d
commit 7bdf2f29c0

View File

@@ -1139,6 +1139,22 @@ public class CollUtilTest {
assertEquals("3", CollUtil.getFirst(deque));
}
@Test
void getFirstTestWithPredicateTest(){
Animal dog = new Animal("dog", 2);
Animal cat = new Animal("cat", 3);
Animal bear = new Animal("bear", 4);
List<Animal> list = new ArrayList<>();
list.add(dog);
list.add(cat);
list.add(bear);
final Animal cat1 = CollUtil.getFirst(list, (t) -> t.getName().equals("cat"));
assertNotNull(cat1);
assertEquals("cat", cat1.getName());
}
@Test
public void popPartTest() {
final Stack<Integer> stack = new Stack<>();