Skip to content

Commit fc95e6b

Browse files
committed
Added extra edge cases
1 parent 8ea4494 commit fc95e6b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/test/java/com/thealgorithms/slidingwindow/CountNiceSubarraysTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,29 @@ void testMultipleChoices() {
2828
int[] nums = {2, 2, 1, 2, 2, 1, 2};
2929
assertEquals(6, CountNiceSubarrays.countNiceSubarrays(nums, 2));
3030
}
31+
32+
@Test
33+
void testTrailingEvenNumbers() {
34+
int[] nums = {1, 2, 2, 2};
35+
assertEquals(4, CountNiceSubarrays.countNiceSubarrays(nums, 1));
36+
}
37+
38+
@Test
39+
void testMultipleWindowShrinks() {
40+
int[] nums = {1, 1, 1, 1};
41+
assertEquals(3, CountNiceSubarrays.countNiceSubarrays(nums, 2));
42+
}
43+
44+
@Test
45+
void testEvensBetweenOdds() {
46+
int[] nums = {2, 1, 2, 1, 2};
47+
assertEquals(4, CountNiceSubarrays.countNiceSubarrays(nums, 2));
48+
}
49+
50+
@Test
51+
void testShrinkWithTrailingEvens() {
52+
int[] nums = {2, 2, 1, 2, 2, 1, 2, 2};
53+
assertEquals(9, CountNiceSubarrays.countNiceSubarrays(nums, 2));
54+
}
55+
3156
}

0 commit comments

Comments
 (0)