MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / getMaxSubArraySumTestCases

Function getMaxSubArraySumTestCases

dynamic/maxsubarraysum_test.go:14–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12}
13
14func 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
28func TestMaxSubArraySum(t *testing.T) {
29 t.Run("Max SubArray Sum test cases", func(t *testing.T) {

Callers 1

TestMaxSubArraySumFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected