File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -30,13 +30,22 @@ func TestSum(t *testing.T) {
3030}
3131
3232func TestSumAll (t * testing.T ) {
33+ t .Run ("make the sums of some slices" , func (t * testing.T ) {
34+ got := SumAll ([]int {1 , 2 }, []int {0 , 9 })
35+ want := []int {3 , 9 }
3336
34- got := SumAll ([]int {1 , 2 }, []int {0 , 9 })
35- want := []int {3 , 9 }
37+ if ! reflect .DeepEqual (got , want ) {
38+ t .Errorf ("got %v want %v" , got , want )
39+ }
40+ })
3641
37- if ! reflect .DeepEqual (got , want ) {
38- t .Errorf ("got %v want %v" , got , want )
39- }
42+ t .Run ("safely sum empty slices" , func (t * testing.T ) {
43+ got := SumAllTails ([]int {}, []int {3 , 4 , 5 })
44+ want := []int {0 , 9 }
45+ if ! reflect .DeepEqual (got , want ) {
46+ t .Errorf ("got %v, want %v" , got , want )
47+ }
48+ })
4049}
4150
4251func TestSumAllTails (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments