Loading slices/slices_test.go +25 −0 Original line number Diff line number Diff line Loading @@ -43,3 +43,28 @@ func TestMapOrderingLogOnly(t *testing.T) { t.Logf("m[%d] = %d", i, v) } } func helperSum(is ...int) int { sum := 0 for _, i := range is { sum += i } return sum } func TestSlicesAndVariadicFunctions(t *testing.T) { ia := []int{ 1, 2, 3, 4, 5, 6, 7, 8, 9, } for i, v := range []int{ helperSum(), helperSum(1), helperSum(1, 2), helperSum(1, 2, 3), helperSum(1, 2, 3, 4), helperSum(1, 2, 3, 4, 5), helperSum(ia...), } { t.Logf("%d: %d", i, v) } } Loading
slices/slices_test.go +25 −0 Original line number Diff line number Diff line Loading @@ -43,3 +43,28 @@ func TestMapOrderingLogOnly(t *testing.T) { t.Logf("m[%d] = %d", i, v) } } func helperSum(is ...int) int { sum := 0 for _, i := range is { sum += i } return sum } func TestSlicesAndVariadicFunctions(t *testing.T) { ia := []int{ 1, 2, 3, 4, 5, 6, 7, 8, 9, } for i, v := range []int{ helperSum(), helperSum(1), helperSum(1, 2), helperSum(1, 2, 3), helperSum(1, 2, 3, 4), helperSum(1, 2, 3, 4, 5), helperSum(ia...), } { t.Logf("%d: %d", i, v) } }