MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestTrapRainWater

Function TestTrapRainWater

dynamic/traprainwater_test.go:10–34  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func 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}

Callers

nothing calls this directly

Calls 1

TrapRainWaterFunction · 0.92

Tested by

no test coverage detected