-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MoreGatherers.zipWithIterable() (#24)
- Loading branch information
Showing
5 changed files
with
52 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
src/test/java/com/pivovarit/gatherers/ZipCollectionMapperTest.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
src/test/java/com/pivovarit/gatherers/ZipWithIterableMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.pivovarit.gatherers; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
import static com.pivovarit.gatherers.MoreGatherers.zipWithIterable; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
class ZipWithIterableMapperTest { | ||
|
||
@Test | ||
void shouldZipEmpty() { | ||
assertThat(Stream.<Integer>empty().gather(zipWithIterable(List.of(1, 2, 3), Integer::sum))).isEmpty(); | ||
} | ||
|
||
@Test | ||
void shouldZipWithEmpty() { | ||
assertThat(Stream.of(1, 2, 3).gather(zipWithIterable(List.of(), Integer::sum))).isEmpty(); | ||
} | ||
|
||
@Test | ||
void shouldZip() { | ||
assertThat(Stream.of(1, 2, 3).gather(zipWithIterable(List.of("a", "b", "c", "d"), (i, s) -> i + s))) | ||
.containsExactly("1a", "2b", "3c"); | ||
} | ||
|
||
@Test | ||
void shouldRejectNullCollection() { | ||
assertThatThrownBy(() -> zipWithIterable(null, (i, _) -> i)).isInstanceOf(NullPointerException.class); | ||
} | ||
|
||
@Test | ||
void shouldRejectNullMapper() { | ||
assertThatThrownBy(() -> zipWithIterable(List.of(1), null)).isInstanceOf(NullPointerException.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters