MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / Test_maxSubArray

Function Test_maxSubArray

maximum_subarray_53/solution_test.go:8–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func Test_maxSubArray(t *testing.T) {
9 type args struct {
10 nums []int
11 }
12 tests := []struct {
13 name string
14 args args
15 want int
16 }{
17 {
18 name: "contiguous subarray which has the largest sum",
19 args: args{
20 nums: []int{-2, 1, -3, 4, -1, 2, 1, -5, 4},
21 },
22 want: 6,
23 },
24 {
25 name: "contiguous subarray which has the largest sum",
26 args: args{
27 nums: []int{-1000, 1000, 1},
28 },
29 want: 1001,
30 },
31 {
32 name: "contiguous subarray which has the largest sum",
33 args: args{
34 nums: []int{-1, 2, -1, -3},
35 },
36 want: 2,
37 },
38 }
39 for _, tt := range tests {
40 t.Run(tt.name, func(t *testing.T) {
41 assert.Equal(t, tt.want, maxSubArray(tt.args.nums))
42 assert.Equal(t, tt.want, maxSubArray2(tt.args.nums))
43 })
44 }
45}

Callers

nothing calls this directly

Calls 2

maxSubArrayFunction · 0.85
maxSubArray2Function · 0.85

Tested by

no test coverage detected