Skip to content

Commit

Permalink
Add more windowSliding() tests (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit authored Oct 16, 2024
1 parent 0d1ff16 commit 180b3b5
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,24 @@ void shouldRejectInvalidStep() {
.hasMessage("'step' must be greater than or equal to zero");
}

@Test
void shouldRejectInvalidWindowSizeAndStep() {
assertThatThrownBy(() -> MoreGatherers.windowSliding(3, 4))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("'step' must be less than or equal to 'windowSize'");
}

@Test
void shouldWindowSlidingEmpty() {
assertThat(Stream.empty().gather(MoreGatherers.windowSliding(2, 1))).isEmpty();
}

@Test
void shouldWindowSlidingWithWindowSizeGreaterThanStreamSize() {
assertThat(Stream.of(1, 2, 3).gather(MoreGatherers.windowSliding(4, 1)))
.containsExactly(of(1, 2, 3));
}

@Test
void shouldWindowSlidingWithStep1() {
assertThat(Stream.of(1, 2, 3, 4, 5).gather(MoreGatherers.windowSliding(2, 1)))
Expand Down

0 comments on commit 180b3b5

Please sign in to comment.