forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrappingRainwaterTest.java
More file actions
38 lines (30 loc) · 908 Bytes
/
TrappingRainwaterTest.java
File metadata and controls
38 lines (30 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.thealgorithms.stacks;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
public class TrappingRainwaterTest {
@Test
public void testExampleCase() {
int[] height = {4, 2, 0, 3, 2, 5};
assertEquals(9, TrappingRainwater.trap(height));
}
@Test
public void testNoTrapping() {
int[] height = {1, 2, 3, 4, 5};
assertEquals(0, TrappingRainwater.trap(height));
}
@Test
public void testFlatSurface() {
int[] height = {0, 0, 0, 0};
assertEquals(0, TrappingRainwater.trap(height));
}
@Test
public void testSymmetricPit() {
int[] height = {3, 0, 2, 0, 3};
assertEquals(7, TrappingRainwater.trap(height));
}
@Test
public void testSingleBar() {
int[] height = {5};
assertEquals(0, TrappingRainwater.trap(height));
}
}