-
Notifications
You must be signed in to change notification settings - Fork 200
Expand file tree
/
Copy pathScanTest.java
More file actions
25 lines (21 loc) · 756 Bytes
/
ScanTest.java
File metadata and controls
25 lines (21 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.github.streams.practice.gatherers;
import java.util.List;
import java.util.stream.Gatherers;
import java.util.stream.Stream;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnJre;
import org.junit.jupiter.api.condition.JRE;
class ScanTest {
@Test
@EnabledOnJre(JRE.JAVA_25)
void scanTest() {
final List<String> actual =
Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9)
.gather(Gatherers.scan(() -> "", (string, number) -> string + number))
.toList();
final List<String> expected =
List.of("1", "12", "123", "1234", "12345", "123456", "1234567", "12345678", "123456789");
Assertions.assertEquals(expected, actual);
}
}