Skip to content
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
irenemrtinez
Java
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
Java
/
src
/
test
/
java
/
com
/
thealgorithms
/
stacks
/
LargestRectangleTest.java
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
28 lines (22 loc) · 1.23 KB
master
Breadcrumbs
Java
/
src
/
test
/
java
/
com
/
thealgorithms
/
stacks
/
LargestRectangleTest.java
Copy path
Top
File metadata and controls
Code
Blame
28 lines (22 loc) · 1.23 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package com.thealgorithms.stacks;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
public class LargestRectangleTest {
@ParameterizedTest(name = "Histogram: {0} → Expected area: {1}")
@MethodSource("histogramProvider")
void testLargestRectangleHistogram(int[] heights, String expected) {
assertEquals(expected, LargestRectangle.largestRectangleHistogram(heights));
}
static Stream<Arguments> histogramProvider() {
return Stream.of(Arguments.of(new int[] {2, 1, 5, 6, 2, 3}, "10"), Arguments.of(new int[] {2, 4}, "4"), Arguments.of(new int[] {4, 4, 4, 4}, "16"), Arguments.of(new int[] {}, "0"), Arguments.of(new int[] {5}, "5"), Arguments.of(new int[] {0, 0, 0}, "0"),
Arguments.of(new int[] {6, 2, 5, 4, 5, 1, 6}, "12"), Arguments.of(new int[] {2, 1, 5, 6, 2, 3, 1}, "10"), Arguments.of(createLargeArray(10000, 1), "10000"));
}
private static int[] createLargeArray(int size, int value) {
int[] arr = new int[size];
java.util.Arrays.fill(arr, value);
return arr;
}
}
You can’t perform that action at this time.