(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func Test_numIslands(t *testing.T) { |
| 9 | type args struct { |
| 10 | grid [][]byte |
| 11 | } |
| 12 | tests := []struct { |
| 13 | name string |
| 14 | args args |
| 15 | want int |
| 16 | }{ |
| 17 | { |
| 18 | name: "number of islands", |
| 19 | args: args{ |
| 20 | grid: [][]byte{ |
| 21 | {1, 1, 1, 1, 0}, |
| 22 | {1, 1, 0, 1, 0}, |
| 23 | {1, 1, 0, 0, 0}, |
| 24 | {0, 0, 0, 0, 0}, |
| 25 | }, |
| 26 | }, |
| 27 | want: 1, |
| 28 | }, |
| 29 | { |
| 30 | name: "number of islands", |
| 31 | args: args{ |
| 32 | grid: [][]byte{ |
| 33 | {1, 1, 0, 0, 0}, |
| 34 | {1, 1, 0, 0, 0}, |
| 35 | {0, 0, 1, 0, 0}, |
| 36 | {0, 0, 0, 1, 1}, |
| 37 | }, |
| 38 | }, |
| 39 | want: 3, |
| 40 | }, |
| 41 | } |
| 42 | for _, tt := range tests { |
| 43 | t.Run(tt.name, func(t *testing.T) { |
| 44 | assert.Equal(t, tt.want, numIslands(tt.args.grid)) |
| 45 | }) |
| 46 | } |
| 47 | } |
nothing calls this directly
no test coverage detected