We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6e0937e commit a087ce4Copy full SHA for a087ce4
arrays-and-slices/sum_test.go
@@ -49,19 +49,20 @@ func TestSumAll(t *testing.T) {
49
}
50
51
func TestSumAllTails(t *testing.T) {
52
- t.Run("make the sums of some slices", func(t *testing.T) {
53
- got := SumAllTails([]int{1, 2}, []int{0, 9})
54
- want := []int{2, 9}
55
-
+ checkSums := func(t testing.TB, got, want []int) {
+ t.Helper()
56
if !reflect.DeepEqual(got, want) {
57
t.Errorf("got %v, want %v", got, want)
58
+ }
+ t.Run("make the sums of some slices", func(t *testing.T) {
59
+ got := SumAllTails([]int{1, 2}, []int{0, 9})
60
+ want := []int{2, 9}
61
+ checkSums(t, got, want)
62
})
63
t.Run("safely sum empty slices", func(t *testing.T) {
64
got := SumAllTails([]int{}, []int{3, 4, 5})
65
want := []int{0, 9}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("got %v, want %v", got, want)
- }
66
67
68
0 commit comments