diff --git a/core-java-modules/core-java-collections-array-list-2/src/test/java/com/baeldung/peakelements/SinglePeakFinderUnitTest.java b/core-java-modules/core-java-collections-array-list-2/src/test/java/com/baeldung/peakelements/SinglePeakFinderUnitTest.java index f2448ec255..9e4cea2c0e 100644 --- a/core-java-modules/core-java-collections-array-list-2/src/test/java/com/baeldung/peakelements/SinglePeakFinderUnitTest.java +++ b/core-java-modules/core-java-collections-array-list-2/src/test/java/com/baeldung/peakelements/SinglePeakFinderUnitTest.java @@ -21,4 +21,12 @@ public class SinglePeakFinderUnitTest { OptionalInt peak = SinglePeakFinder.findSinglePeak(arr); 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()); + } }