!770 对EasyStream中补充peekIdx()方法,修改mapMulti()方法适配于更高版本JDK

Merge pull request !770 from ZVerify/v6-dev
This commit is contained in:
Looly
2022-08-26 01:23:19 +00:00
committed by Gitee
2 changed files with 47 additions and 1 deletions

View File

@@ -208,6 +208,26 @@ public class EasyStreamTest {
Assert.assertEquals(Arrays.asList(-1, -1, -1), EasyStream.of(1, 2, 3).parallel().flatMapIdx((e, i) -> EasyStream.of(i)).toList());
}
@Test
public void testPeek(){
EasyStream.of("one", "two", "three", "four")
.filter(e -> e.length() == 4)
.peek(e -> Assert.assertEquals("four", e))
.map(String::toUpperCase)
.peek(e -> Assert.assertEquals("FOUR", e))
.collect(Collectors.toList());
}
@Test
public void testPeekIdx(){
EasyStream.of("one", "two", "three", "four")
.filter(e -> e.length() == 4)
.peekIdx((e,i) -> Assert.assertEquals("four:0", e + ":" + i))
.map(String::toUpperCase)
.peekIdx((e,i) -> Assert.assertEquals("FOUR:0", e + ":" + i))
.collect(Collectors.toList());
}
@Test
public void testFlat() {
final List<Integer> list = Arrays.asList(1, 2, 3);