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