()
| 12 | } |
| 13 | |
| 14 | func getMaxSubArraySumTestCases() []testCaseMaxSubArraySum { |
| 15 | return []testCaseMaxSubArraySum{ |
| 16 | {[]int{-2, -3, 4, -1, -2, 1, 5, -3}, 7}, // Kadane's algorithm example |
| 17 | {[]int{-1, -2, -3, -4}, -1}, // All negative numbers, max single element |
| 18 | {[]int{5, 4, -1, 7, 8}, 23}, // Positive numbers with a large sum |
| 19 | {[]int{-2, 1, -3, 4, -1, 2, 1, -5, 4}, 6}, // Mixed with a maximum subarray of length 4 |
| 20 | {[]int{1, 2, 3, 4, 5}, 15}, // All positive numbers, sum is the entire array |
| 21 | {[]int{-1, -2, -3, -4, -5}, -1}, // Only negative numbers, largest single element |
| 22 | {[]int{0, 0, 0, 0, 0}, 0}, // Array of zeros, maximum subarray is zero |
| 23 | {[]int{3}, 3}, // Single positive number |
| 24 | {[]int{-1}, -1}, // Single negative number |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | func TestMaxSubArraySum(t *testing.T) { |
| 29 | t.Run("Max SubArray Sum test cases", func(t *testing.T) { |
no outgoing calls
no test coverage detected