-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathResultTest.java
More file actions
28 lines (22 loc) · 815 Bytes
/
ResultTest.java
File metadata and controls
28 lines (22 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package hackrank.algorithm.dynamic.maxsub;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
class ResultTest {
@Test
void maxSubarray_AllPositive_SumOfEverything() {
List<Integer> result = Result.maxSubarray(Arrays.asList(1, 2, 3, 4));
assertThat(result).containsExactly(10, 10);
}
@Test
void maxSubarray_Example_ExpectedMax() {
List<Integer> result = Result.maxSubarray(Arrays.asList(-1, 2, 3, -4, 5, 10));
assertThat(result).containsExactly(16, 20);
}
@Test
void maxSubarray_AllNegative_PickMinNegative() {
List<Integer> result = Result.maxSubarray(Arrays.asList(-20, -7, -99, -4));
assertThat(result).containsExactly(-4, -4);
}
}