Update SinglePeakFinderUnitTest.java

This commit is contained in:
Imran Alam 2024-03-06 12:01:13 +05:30 committed by GitHub
parent 16b8708d25
commit 2f18d71810
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 0 deletions

View File

@ -21,4 +21,12 @@ public class SinglePeakFinderUnitTest {
OptionalInt peak = SinglePeakFinder.findSinglePeak(arr); OptionalInt peak = SinglePeakFinder.findSinglePeak(arr);
assertTrue(peak.isEmpty()); assertTrue(peak.isEmpty());
} }
@Test
void findSinglePeak_givenEqualElementArray_thenReturnsCorrectPeak() {
int[] arr = {-2, -2, -2, -2, -2};
OptionalInt peak = SinglePeakFinder.findSinglePeak(arr);
assertTrue(peak.isPresent());
assertEquals(-2, peak.getAsInt());
}
} }