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) {
30
30
}
31
31
32
32
func 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 }
33
36
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
+ })
36
41
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
+ })
40
49
}
41
50
42
51
func TestSumAllTails (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments