Skip to content

Commit

Permalink
Expand tests for zip Gatherers (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit authored Oct 14, 2024
1 parent 6fb6341 commit a6986be
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object>) null, (i, _) -> i)).isInstanceOf(NullPointerException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object>) null)).isInstanceOf(NullPointerException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object>) null, (i, _) -> i)).isInstanceOf(NullPointerException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object>) null)).isInstanceOf(NullPointerException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a6986be

Please sign in to comment.