forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearch2DMatrixTest.java
More file actions
30 lines (26 loc) · 875 Bytes
/
Search2DMatrixTest.java
File metadata and controls
30 lines (26 loc) · 875 Bytes
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
29
30
package com.thealgorithms.matrix;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
public class Search2DMatrixTest {
@Test
public void testSearchMatrixSortedRowsAndCols() {
int[][] matrix = {
{1, 4, 7, 11},
{2, 5, 8, 12},
{3, 6, 9, 16},
{10, 13, 14, 17}
};
assertTrue(Search2DMatrix.searchMatrixSortedRowsAndCols(matrix, 5));
assertFalse(Search2DMatrix.searchMatrixSortedRowsAndCols(matrix, 20));
}
@Test
public void testSearchMatrixFlattenedSorted() {
int[][] matrix = {
{1, 3, 5, 7},
{10, 11, 16, 20},
{23, 30, 34, 50}
};
assertTrue(Search2DMatrix.searchMatrixFlattenedSorted(matrix, 3));
assertFalse(Search2DMatrix.searchMatrixFlattenedSorted(matrix, 4));
}
}