mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Refactor files to be in correctly nested packages (#6120)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.thealgorithms.matrix;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MedianOfMatrixTest {
|
||||
|
||||
@Test
|
||||
public void testMedianWithOddNumberOfElements() {
|
||||
List<List<Integer>> matrix = new ArrayList<>();
|
||||
matrix.add(Arrays.asList(1, 3, 5));
|
||||
matrix.add(Arrays.asList(2, 4, 6));
|
||||
matrix.add(Arrays.asList(7, 8, 9));
|
||||
|
||||
int result = MedianOfMatrix.median(matrix);
|
||||
|
||||
assertEquals(5, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMedianWithEvenNumberOfElements() {
|
||||
List<List<Integer>> matrix = new ArrayList<>();
|
||||
matrix.add(Arrays.asList(2, 4));
|
||||
matrix.add(Arrays.asList(1, 3));
|
||||
|
||||
int result = MedianOfMatrix.median(matrix);
|
||||
|
||||
assertEquals(2, result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user