26 lines
420 B
Go
26 lines
420 B
Go
package collections
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestSum(t *testing.T) {
|
|
numbers := []int{1, 2, 3, 4, 5}
|
|
|
|
got := Sum(numbers)
|
|
want := 15
|
|
|
|
if got != want {
|
|
t.Errorf("got %d want %d given %v", got, want, numbers)
|
|
}
|
|
}
|
|
|
|
func TestSumAll(t *testing.T) {
|
|
got := SumAll([]int{1, 2}, []int{1, 2, 3, 4, 5})
|
|
want := []int{3, 15}
|
|
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Errorf("got %d want %d", got, want)
|
|
}
|
|
}
|