Skip to content

Commit

Permalink
test: write test code about maxSubarrayWithBruteforceOptimized
Browse files Browse the repository at this point in the history
  • Loading branch information
rldnrl committed Nov 26, 2022
1 parent 48cb14c commit 1cba0d9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/leetcode/MaximumSubarrayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ void maximumSubarrayWithBruteforceTest() {
Assertions.assertEquals(MaximumSubarray.maxSubarrayWithBruteforce(nums3), result3);
}

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

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

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

int[] nums4 = new int[]{-5, -4,-1, -7, -8};
int result4 = -1;
Assertions.assertEquals(MaximumSubarray.maxSubarrayWithBruteforceOptimized(nums4), result4);
}

@Test
void maximumSubarrayWithSlidingWindow() {
int[] nums1 = new int[]{-2,1,-3,4,-1,2,1,-5,4};
Expand Down

0 comments on commit 1cba0d9

Please sign in to comment.