1
+ package com .thealgorithms .searches ;
2
+
3
+ import static org .junit .jupiter .api .Assertions .*;
4
+ import org .junit .jupiter .api .Test ;
5
+
6
+ public class TestSearchInARowAndColWiseSortedMatrix {
7
+ @ Test
8
+ public void searchItem () {
9
+ int [][] matrix = {
10
+ { 3 , 4 , 5 , 6 , 7 },
11
+ { 8 , 9 , 10 , 11 , 12 },
12
+ { 14 , 15 , 16 , 17 , 18 },
13
+ { 23 , 24 , 25 , 26 , 27 },
14
+ { 30 , 31 , 32 , 33 , 34 }
15
+ };
16
+
17
+ var test = new SearchInARowAndColWiseSortedMatrix ();
18
+ int [] res = test .search (matrix , 16 );
19
+ int [] expectedResult = { 2 , 2 };
20
+ assertArrayEquals (expectedResult , res );
21
+ }
22
+
23
+ @ Test
24
+ public void notFound () {
25
+ int [][] matrix = {
26
+ { 3 , 4 , 5 , 6 , 7 },
27
+ { 8 , 9 , 10 , 11 , 12 },
28
+ { 14 , 15 , 16 , 17 , 18 },
29
+ { 23 , 24 , 25 , 26 , 27 },
30
+ { 30 , 31 , 32 , 33 , 34 }
31
+ };
32
+
33
+ var test = new SearchInARowAndColWiseSortedMatrix ();
34
+ int [] res = test .search (matrix , 96 );
35
+ int [] expectedResult = { -1 , -1 };
36
+ assertArrayEquals (expectedResult , res );
37
+ }
38
+ }
0 commit comments