diff --git a/src/test/java/com/pivovarit/gatherers/blackbox/WindowSlidingTest.java b/src/test/java/com/pivovarit/gatherers/blackbox/WindowSlidingTest.java index 8403612..35a3838 100644 --- a/src/test/java/com/pivovarit/gatherers/blackbox/WindowSlidingTest.java +++ b/src/test/java/com/pivovarit/gatherers/blackbox/WindowSlidingTest.java @@ -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)))