Skip to content

Commit 268b52a

Browse files
committed
Add test case for map multi operation
1 parent b525212 commit 268b52a

File tree

1 file changed

+19
-0
lines changed
  • JavaReleases/src/test/java/pl/mperor/lab/java

1 file changed

+19
-0
lines changed

JavaReleases/src/test/java/pl/mperor/lab/java/Java16.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,25 @@ private static boolean nonEmptyString(Object obj) {
8484
return (obj instanceof String str) && !str.isEmpty();
8585
}
8686

87+
@Test
88+
public void testMapMultiForManagingExceptionsInParsing() {
89+
String valuesAsString = """
90+
1
91+
2
92+
@@@@@ buggy
93+
3""";
94+
95+
var parsed = valuesAsString.lines()
96+
.mapMultiToInt((line, consumer) -> {
97+
try {
98+
int i = Integer.parseInt(line);
99+
consumer.accept(i);
100+
} catch (NumberFormatException _) {}
101+
}).toArray();
102+
103+
Assertions.assertArrayEquals(new int[]{1, 2, 3}, parsed);
104+
}
105+
87106
@SuppressWarnings({"removal", "synchronization"})
88107
@Test
89108
public void testValueBasedClasses() {

0 commit comments

Comments
 (0)