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) · 940 Bytes
/
TrappingRainWaterTest.java
File metadata and controls
38 lines (30 loc) · 940 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.searches;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
public class TrappingRainWaterTest {
@Test
public void testExample() {
int[] height = {4, 2, 0, 3, 2, 5};
assertEquals(9, TrappingRainWater.trap(height));
}
@Test
public void testEmpty() {
int[] height = {};
assertEquals(0, TrappingRainWater.trap(height));
}
@Test
public void testNoTrapping() {
int[] height = {0, 1, 2, 3, 4};
assertEquals(0, TrappingRainWater.trap(height));
}
@Test
public void testFlat() {
int[] height = {3, 3, 3, 3};
assertEquals(0, TrappingRainWater.trap(height));
}
@Test
public void testNull() {
assertThrows(IllegalArgumentException.class, () -> TrappingRainWater.trap(null));
}
}