mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
add test
This commit is contained in:
parent
5febb65d7c
commit
87a1cec9ed
@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.collection;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Iterator;
|
||||
@ -15,17 +16,25 @@ public class FilterIterTest {
|
||||
Iterator<String> it = ListUtil.of("1", "2").iterator();
|
||||
// filter 为null
|
||||
FilterIter<String> filterIter = new FilterIter<>(it, null);
|
||||
while (filterIter.hasNext()) {
|
||||
System.out.println(filterIter.next());
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
int count = 0;
|
||||
while (filterIter.hasNext()) {
|
||||
if(filterIter.next() != null){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(2, count);
|
||||
|
||||
it = ListUtil.of("1", "2").iterator();
|
||||
// filter 不为空
|
||||
filterIter = new FilterIter<>(it, (key) -> key.equals("1"));
|
||||
count = 0;
|
||||
while (filterIter.hasNext()) {
|
||||
System.out.println(filterIter.next());
|
||||
if(filterIter.next() != null){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(1, count);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user