1
1
package com .thealgorithms .slidingwindow ;
2
+
2
3
import static org .junit .jupiter .api .Assertions .assertEquals ;
4
+
3
5
import org .junit .jupiter .api .Test ;
6
+
4
7
/**
5
8
* Unit tests for the MinSumKSizeSubarray class.
6
- *
9
+ *
7
10
* @author Rashi Dashore (https://github.com/rashi07dashore)
8
11
*/
9
12
class MinSumKSizeSubarrayTest {
13
+
10
14
/**
11
15
* Test for the basic case of finding the minimum sum.
12
16
*/
@@ -17,6 +21,7 @@ void testMinSumKSizeSubarray() {
17
21
int expectedMinSum = 3 ; // 1 + 1 + 1
18
22
assertEquals (expectedMinSum , MinSumKSizeSubarray .minSumKSizeSubarray (arr , k ));
19
23
}
24
+
20
25
/**
21
26
* Test for a different array and subarray size.
22
27
*/
@@ -27,6 +32,7 @@ void testMinSumKSizeSubarrayWithDifferentValues() {
27
32
int expectedMinSum = 3 ; // 1 + 2
28
33
assertEquals (expectedMinSum , MinSumKSizeSubarray .minSumKSizeSubarray (arr , k ));
29
34
}
35
+
30
36
/**
31
37
* Test for edge case with insufficient elements.
32
38
*/
@@ -37,6 +43,7 @@ void testMinSumKSizeSubarrayWithInsufficientElements() {
37
43
int expectedMinSum = -1 ; // Edge case
38
44
assertEquals (expectedMinSum , MinSumKSizeSubarray .minSumKSizeSubarray (arr , k ));
39
45
}
46
+
40
47
/**
41
48
* Test for large array.
42
49
*/
@@ -47,6 +54,7 @@ void testMinSumKSizeSubarrayWithLargeArray() {
47
54
int expectedMinSum = -10 ; // -1 + -2 + -3 + -4 + 0
48
55
assertEquals (expectedMinSum , MinSumKSizeSubarray .minSumKSizeSubarray (arr , k ));
49
56
}
57
+
50
58
/**
51
59
* Test for array with negative numbers.
52
60
*/
@@ -57,6 +65,7 @@ void testMinSumKSizeSubarrayWithNegativeNumbers() {
57
65
int expectedMinSum = -9 ; // -4 + -5
58
66
assertEquals (expectedMinSum , MinSumKSizeSubarray .minSumKSizeSubarray (arr , k ));
59
67
}
68
+
60
69
/**
61
70
* Test for the case where k equals the array length.
62
71
*/
0 commit comments