mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-25 00:24:45 +01:00
44 lines
624 B
Go
44 lines
624 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestLargestSumOfTriangle(t *testing.T) {
|
|
tt := []struct {
|
|
name string
|
|
input [][]int
|
|
want int
|
|
}{
|
|
{
|
|
"example",
|
|
[][]int{{3}, {7, 4}, {2, 4, 6}, {8, 5, 9, 3}},
|
|
23,
|
|
},
|
|
{
|
|
"example_2",
|
|
[][]int{{3}, {7, 4}},
|
|
10,
|
|
},
|
|
{
|
|
"example_3",
|
|
[][]int{{3}},
|
|
3,
|
|
},
|
|
{
|
|
"example_4",
|
|
[][]int{{3}, {7, 4}, {2, 4, 6}},
|
|
14,
|
|
},
|
|
}
|
|
|
|
for _, tc := range tt {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
got := LargestSumOfTriangle(tc.input)
|
|
if got != tc.want {
|
|
t.Errorf("LargestSumOfTriangle(%v)=%d, want %d", tc.input, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|