mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
refactor: improving Median (#6404)
refactor: improving Median Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
b45fd2a656
commit
31bf130e9e
@@ -1,6 +1,7 @@
|
||||
package com.thealgorithms.maths;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -34,4 +35,10 @@ public class MedianTest {
|
||||
int[] arr = {-27, -16, -7, -4, -2, -1};
|
||||
assertEquals(-5.5, Median.median(arr));
|
||||
}
|
||||
|
||||
@Test
|
||||
void medianEmptyArrayThrows() {
|
||||
int[] arr = {};
|
||||
assertThrows(IllegalArgumentException.class, () -> Median.median(arr));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user