diff --git a/sum/sum.go b/sum/sum.go index a403234..8667504 100644 --- a/sum/sum.go +++ b/sum/sum.go @@ -8,3 +8,7 @@ func Sum(numbers []int) int { } return sum } + +func SumAll(x []int, y []int) []int { + return []int{Sum(x), Sum(y)} +} diff --git a/sum/sum_test.go b/sum/sum_test.go index e925ab5..03f38fd 100644 --- a/sum/sum_test.go +++ b/sum/sum_test.go @@ -1,6 +1,9 @@ package sum -import "testing" +import ( + "slices" + "testing" +) func TestSum(t *testing.T) { t.Run("collection of 5 numbers", func(t *testing.T) { @@ -13,15 +16,12 @@ func TestSum(t *testing.T) { t.Errorf("got %d, expected %d, given %v", got, exp, numbers) } }) - - t.Run("collection of any size", func(t *testing.T) { - numbers := []int{1, 2, 3} - - got := Sum(numbers) - exp := 6 - - if got != exp { - t.Errorf("got %d, expected %d, given %v", got, exp, numbers) - } - }) +} + +func TestSumAll(t *testing.T) { + got := SumAll([]int{1, 2}, []int{0, 9}) + exp := []int{3, 9} + if slices.Compare(got, exp) != 0 { + t.Errorf("got %d, expected %d", got, exp) + } }