(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestTrapRainWater(t *testing.T) { |
| 11 | heights := [][]int{ |
| 12 | {}, |
| 13 | {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1}, |
| 14 | {4, 2, 0, 3, 2, 5}, |
| 15 | {3, 1, 2, 4, 0, 1, 3, 2, 4}, |
| 16 | } |
| 17 | |
| 18 | expectedResults := []int{ |
| 19 | 0, |
| 20 | 6, |
| 21 | 9, |
| 22 | 13, |
| 23 | } |
| 24 | |
| 25 | for i, height := range heights { |
| 26 | expected := expectedResults[i] |
| 27 | t.Run(fmt.Sprintf("Case %d", i+1), func(t *testing.T) { |
| 28 | result := dynamic.TrapRainWater(height) |
| 29 | if result != expected { |
| 30 | t.Errorf("Expected %d, but got %d", expected, result) |
| 31 | } |
| 32 | }) |
| 33 | } |
| 34 | } |
nothing calls this directly
no test coverage detected