diff --git a/src/test/java/com/pivovarit/gatherers/blackbox/ZipIteratorMapperTest.java b/src/test/java/com/pivovarit/gatherers/blackbox/ZipIteratorMapperTest.java index 455eaa5..b436c2e 100644 --- a/src/test/java/com/pivovarit/gatherers/blackbox/ZipIteratorMapperTest.java +++ b/src/test/java/com/pivovarit/gatherers/blackbox/ZipIteratorMapperTest.java @@ -28,6 +28,12 @@ void shouldZip() { .containsExactly("1a", "2b", "3c"); } + @Test + void shouldZipWithShorter() { + assertThat(Stream.of(1, 2, 3).gather(zip(List.of("a", "b").iterator(), (i, s) -> i + s))) + .containsExactly("1a", "2b"); + } + @Test void shouldRejectNullIterator() { assertThatThrownBy(() -> zip((Iterator) null, (i, _) -> i)).isInstanceOf(NullPointerException.class); diff --git a/src/test/java/com/pivovarit/gatherers/blackbox/ZipIteratorTest.java b/src/test/java/com/pivovarit/gatherers/blackbox/ZipIteratorTest.java index 71853af..7280618 100644 --- a/src/test/java/com/pivovarit/gatherers/blackbox/ZipIteratorTest.java +++ b/src/test/java/com/pivovarit/gatherers/blackbox/ZipIteratorTest.java @@ -32,6 +32,15 @@ void shouldZip() { ); } + @Test + void shouldZipWithShorter() { + assertThat(Stream.of(1, 2, 3).gather(zip(Stream.of("a", "b").iterator()))) + .containsExactly( + entry(1, "a"), + entry(2, "b") + ); + } + @Test void shouldRejectNullIterator() { assertThatThrownBy(() -> zip((Iterator) null)).isInstanceOf(NullPointerException.class); diff --git a/src/test/java/com/pivovarit/gatherers/blackbox/ZipStreamMapperTest.java b/src/test/java/com/pivovarit/gatherers/blackbox/ZipStreamMapperTest.java index 9efbcef..8b908f3 100644 --- a/src/test/java/com/pivovarit/gatherers/blackbox/ZipStreamMapperTest.java +++ b/src/test/java/com/pivovarit/gatherers/blackbox/ZipStreamMapperTest.java @@ -27,6 +27,12 @@ void shouldZip() { .containsExactly("1a", "2b", "3c"); } + @Test + void shouldZipWithShorter() { + assertThat(Stream.of(1, 2, 3).gather(zip(Stream.of("a", "b"), (i, s) -> i + s))) + .containsExactly("1a", "2b"); + } + @Test void shouldRejectNullStream() { assertThatThrownBy(() -> zip((Stream) null, (i, _) -> i)).isInstanceOf(NullPointerException.class); diff --git a/src/test/java/com/pivovarit/gatherers/blackbox/ZipStreamTest.java b/src/test/java/com/pivovarit/gatherers/blackbox/ZipStreamTest.java index 16c9bc6..0b04bf7 100644 --- a/src/test/java/com/pivovarit/gatherers/blackbox/ZipStreamTest.java +++ b/src/test/java/com/pivovarit/gatherers/blackbox/ZipStreamTest.java @@ -32,6 +32,15 @@ void shouldZip() { ); } + @Test + void shouldZipWithShorter() { + assertThat(Stream.of(1, 2, 3).gather(zip(Stream.of("a", "b")))) + .containsExactly( + entry(1, "a"), + entry(2, "b") + ); + } + @Test void shouldRejectNullStream() { assertThatThrownBy(() -> zip((Iterator) null)).isInstanceOf(NullPointerException.class); diff --git a/src/test/java/com/pivovarit/gatherers/blackbox/ZipWithIterableMapperTest.java b/src/test/java/com/pivovarit/gatherers/blackbox/ZipWithIterableMapperTest.java index 227471a..b4ba729 100644 --- a/src/test/java/com/pivovarit/gatherers/blackbox/ZipWithIterableMapperTest.java +++ b/src/test/java/com/pivovarit/gatherers/blackbox/ZipWithIterableMapperTest.java @@ -27,6 +27,12 @@ void shouldZip() { .containsExactly("1a", "2b", "3c"); } + @Test + void shouldZipWithShorter() { + assertThat(Stream.of(1, 2, 3).gather(zipWithIterable(List.of("a", "b"), (i, s) -> i + s))) + .containsExactly("1a", "2b"); + } + @Test void shouldRejectNullCollection() { assertThatThrownBy(() -> zipWithIterable(null, (i, _) -> i)).isInstanceOf(NullPointerException.class); diff --git a/src/test/java/com/pivovarit/gatherers/blackbox/ZipWithIterableTest.java b/src/test/java/com/pivovarit/gatherers/blackbox/ZipWithIterableTest.java index a0c2098..ae5f912 100644 --- a/src/test/java/com/pivovarit/gatherers/blackbox/ZipWithIterableTest.java +++ b/src/test/java/com/pivovarit/gatherers/blackbox/ZipWithIterableTest.java @@ -32,6 +32,15 @@ void shouldZip() { ); } + @Test + void shouldZipWithShorter() { + assertThat(Stream.of(1, 2, 3).gather(zipWithIterable(List.of("a", "b")))) + .containsExactly( + entry(1, "a"), + entry(2, "b") + ); + } + @Test void shouldRejectNullCollection() { assertThatThrownBy(() -> zipWithIterable(null)).isInstanceOf(NullPointerException.class);