Skip to content

Commit

Permalink
test: write test MaximumSubarray using sliding window
Browse files Browse the repository at this point in the history
  • Loading branch information
rldnrl committed Nov 26, 2022
1 parent 8341a2d commit 4100f74
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/leetcode/MaximumSubarrayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class MaximumSubarrayTest {
@Test
void maximumSubarrayTest() {
void maximumSubarrayWithBruteforceTest() {
int[] nums1 = new int[]{-2,1,-3,4,-1,2,1,-5,4};
int result1 = 6;
Assertions.assertEquals(MaximumSubarray.maxSubarrayWithBruteforce(nums1), result1);
Expand All @@ -18,4 +18,19 @@ void maximumSubarrayTest() {
int result3 = 23;
Assertions.assertEquals(MaximumSubarray.maxSubarrayWithBruteforce(nums3), result3);
}

@Test
void maximumSubarrayWithSlidingWindow() {
int[] nums1 = new int[]{-2,1,-3,4,-1,2,1,-5,4};
int result1 = 6;
Assertions.assertEquals(MaximumSubarray.maxSubarrayWithSlidingWindow(nums1), result1);

int[] nums2 = new int[]{1};
int result2 = 1;
Assertions.assertEquals(MaximumSubarray.maxSubarrayWithSlidingWindow(nums2), result2);

int[] nums3 = new int[]{5,4,-1,7,8};
int result3 = 23;
Assertions.assertEquals(MaximumSubarray.maxSubarrayWithSlidingWindow(nums3), result3);
}
}

0 comments on commit 4100f74

Please sign in to comment.