Skip to content

Commit 66a51b2

Browse files
committed
074 (2) update tests
1 parent ede59f7 commit 66a51b2

File tree

1 file changed

+142
-12
lines changed

1 file changed

+142
-12
lines changed

test/_074_SearchA2DMatrix/SolutionConvertTo1DTest.java

Lines changed: 142 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ public void tearDown() throws Exception {
2828

2929
@Test
3030
public void Test1() {
31-
int[][] matrix = { { 1, 3, 5, 7 }, { 10, 11, 16, 20 },
32-
{ 23, 30, 34, 50 } };
31+
int[][] matrix = {
32+
{ 1, 3, 5, 7 },
33+
{ 10, 11, 16, 20 },
34+
{ 23, 30, 34, 50 }
35+
};
3336
int target = 3;
3437
boolean actual = solution.searchMatrix(matrix, target);
3538
boolean expected = true;
@@ -38,8 +41,11 @@ public void Test1() {
3841

3942
@Test
4043
public void Test2() {
41-
int[][] matrix = { { 1, 3, 5, 7 }, { 10, 11, 16, 20 },
42-
{ 23, 30, 34, 50 } };
44+
int[][] matrix = {
45+
{ 1, 3, 5, 7 },
46+
{ 10, 11, 16, 20 },
47+
{ 23, 30, 34, 50 }
48+
};
4349
int target = 100;
4450
boolean actual = solution.searchMatrix(matrix, target);
4551
boolean expected = false;
@@ -48,8 +54,11 @@ public void Test2() {
4854

4955
@Test
5056
public void Test3() {
51-
int[][] matrix = { { 1, 3, 5, 7 }, { 10, 11, 16, 20 },
52-
{ 23, 30, 34, 50 } };
57+
int[][] matrix = {
58+
{ 1, 3, 5, 7 },
59+
{ 10, 11, 16, 20 },
60+
{ 23, 30, 34, 50 }
61+
};
5362
int target = 15;
5463
boolean actual = solution.searchMatrix(matrix, target);
5564
boolean expected = false;
@@ -58,8 +67,11 @@ public void Test3() {
5867

5968
@Test
6069
public void Test4() {
61-
int[][] matrix = { { 1, 3, 5, 7 }, { 10, 11, 16, 20 },
62-
{ 23, 30, 34, 50 } };
70+
int[][] matrix = {
71+
{ 1, 3, 5, 7 },
72+
{ 10, 11, 16, 20 },
73+
{ 23, 30, 34, 50 }
74+
};
6375
int target = 30;
6476
boolean actual = solution.searchMatrix(matrix, target);
6577
boolean expected = true;
@@ -68,8 +80,11 @@ public void Test4() {
6880

6981
@Test
7082
public void Test5() {
71-
int[][] matrix = { { 1, 3, 5, 7 }, { 10, 11, 16, 20 },
72-
{ 23, 30, 34, 50 } };
83+
int[][] matrix = {
84+
{ 1, 3, 5, 7 },
85+
{ 10, 11, 16, 20 },
86+
{ 23, 30, 34, 50 }
87+
};
7388
int target = 0;
7489
boolean actual = solution.searchMatrix(matrix, target);
7590
boolean expected = false;
@@ -78,12 +93,127 @@ public void Test5() {
7893

7994
@Test
8095
public void Test6() {
81-
int[][] matrix = { { 1, 3, 5, 7 }, { 10, 11, 16, 20 },
82-
{ 23, 30, 34, 50 } };
96+
int[][] matrix = {
97+
{ 1, 3, 5, 7 },
98+
{ 10, 11, 16, 20 },
99+
{ 23, 30, 34, 50 }
100+
};
83101
int target = 10;
84102
boolean actual = solution.searchMatrix(matrix, target);
85103
boolean expected = true;
86104
assertEquals(expected, actual);
87105
}
88106

107+
@Test
108+
public void Test7() {
109+
int[][] matrix = { { 1, 3, 5, 7 } };
110+
int target = 10;
111+
assertFalse(solution.searchMatrix(matrix, target));
112+
}
113+
114+
@Test
115+
public void Test8() {
116+
int[][] matrix = { { 1, 3, 5, 7 } };
117+
int target = 7;
118+
assertTrue(solution.searchMatrix(matrix, target));
119+
}
120+
121+
@Test
122+
public void Test9() {
123+
int[][] matrix = { { 1, 3, 5, 7 } };
124+
int target = 1;
125+
assertTrue(solution.searchMatrix(matrix, target));
126+
}
127+
128+
@Test
129+
public void Test10() {
130+
int[][] matrix = { { 1, 3, 5, 7 } };
131+
int target = 4;
132+
assertFalse(solution.searchMatrix(matrix, target));
133+
}
134+
135+
@Test
136+
public void Test11() {
137+
int[][] matrix = { { 1, 3, 5, 7 } };
138+
int target = 5;
139+
assertTrue(solution.searchMatrix(matrix, target));
140+
}
141+
142+
@Test
143+
public void Test12() {
144+
int[][] matrix = {
145+
{ 1 },
146+
{ 5 },
147+
{ 9 },
148+
};
149+
int target = 9;
150+
assertTrue(solution.searchMatrix(matrix, target));
151+
}
152+
153+
@Test
154+
public void Test13() {
155+
int[][] matrix = {
156+
{ 1 },
157+
{ 5 },
158+
{ 9 },
159+
};
160+
int target = 1;
161+
assertTrue(solution.searchMatrix(matrix, target));
162+
}
163+
164+
@Test
165+
public void Test14() {
166+
int[][] matrix = {
167+
{ 1 },
168+
{ 5 },
169+
{ 9 },
170+
};
171+
int target = 5;
172+
assertTrue(solution.searchMatrix(matrix, target));
173+
}
174+
175+
@Test
176+
public void Test15() {
177+
int[][] matrix = {
178+
{ 1 },
179+
{ 5 },
180+
{ 9 },
181+
};
182+
int target = 18;
183+
assertFalse(solution.searchMatrix(matrix, target));
184+
}
185+
186+
@Test
187+
public void Test16() {
188+
int[][] matrix = {
189+
{ 1 },
190+
{ 5 },
191+
{ 9 },
192+
};
193+
int target = 0;
194+
assertFalse(solution.searchMatrix(matrix, target));
195+
}
196+
197+
@Test
198+
public void Test17() {
199+
int[][] matrix = {
200+
{ 1 },
201+
{ 5 },
202+
{ 9 },
203+
};
204+
int target = 3;
205+
assertFalse(solution.searchMatrix(matrix, target));
206+
}
207+
208+
@Test
209+
public void Test18() {
210+
int[][] matrix = {
211+
{ 1 },
212+
{ 5 },
213+
{ 9 },
214+
};
215+
int target = 7;
216+
assertFalse(solution.searchMatrix(matrix, target));
217+
}
218+
89219
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy